mirror of
https://github.com/fleschutz/PowerShell.git
synced 2024-12-16 19:50:45 +01:00
33 lines
766 B
PowerShell
Executable File
33 lines
766 B
PowerShell
Executable File
<#
|
|
.SYNOPSIS
|
|
Plays the given audio files (supporting MP3 and WAV format)
|
|
.DESCRIPTION
|
|
play-files.ps1 [<FilePattern>]
|
|
.EXAMPLE
|
|
PS> ./play-files *.mp3
|
|
.NOTES
|
|
Author: Markus Fleschutz · License: CC0
|
|
.LINK
|
|
https://github.com/fleschutz/PowerShell
|
|
#>
|
|
|
|
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: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
|
exit 1
|
|
}
|