mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-08-19 08:52:05 +02:00
Rename folder Docs to docs
This commit is contained in:
79
docs/play-files.md
Normal file
79
docs/play-files.md
Normal file
@@ -0,0 +1,79 @@
|
||||
*play-files.ps1*
|
||||
================
|
||||
|
||||
This PowerShell script plays the given audio files (supporting MP3 and WAV format).
|
||||
|
||||
Parameters
|
||||
----------
|
||||
```powershell
|
||||
PS> ./play-files.ps1 [[-FilePattern] <String>] [<CommonParameters>]
|
||||
|
||||
-FilePattern <String>
|
||||
Specifies the file pattern
|
||||
|
||||
Required? false
|
||||
Position? 1
|
||||
Default value *
|
||||
Accept pipeline input? false
|
||||
Accept wildcard characters? false
|
||||
|
||||
[<CommonParameters>]
|
||||
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
|
||||
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
|
||||
```
|
||||
|
||||
Example
|
||||
-------
|
||||
```powershell
|
||||
PS> ./play-files *.mp3
|
||||
|
||||
```
|
||||
|
||||
Notes
|
||||
-----
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
|
||||
Related Links
|
||||
-------------
|
||||
https://github.com/fleschutz/PowerShell
|
||||
|
||||
Script Content
|
||||
--------------
|
||||
```powershell
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Plays audio files (MP3 and WAV)
|
||||
.DESCRIPTION
|
||||
This PowerShell script plays the given audio files (supporting MP3 and WAV format).
|
||||
.PARAMETER FilePattern
|
||||
Specifies the file pattern
|
||||
.EXAMPLE
|
||||
PS> ./play-files *.mp3
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
param([string]$FilePattern = "*")
|
||||
|
||||
try {
|
||||
$Files = (get-childItem -path "$FilePattern" -attributes !Directory)
|
||||
"Playing $($Files.Count) files ..."
|
||||
foreach ($File in $Files) {
|
||||
if ("$File" -like "*.mp3") {
|
||||
& "$PSScriptRoot/play-mp3.ps1" "$File"
|
||||
} elseif ("$File" -like "*.wav") {
|
||||
& "$PSScriptRoot/play-mp3.ps1" "$File"
|
||||
} else {
|
||||
"Skipping $File ..."
|
||||
}
|
||||
}
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of play-files.ps1 as of 10/19/2023 08:11:41)*
|
Reference in New Issue
Block a user