Add play-files.ps1

This commit is contained in:
Markus Fleschutz 2021-05-01 09:26:26 +02:00
parent 9bd33214b1
commit a378f3ae47
3 changed files with 26 additions and 0 deletions

View File

@ -134,6 +134,7 @@ open-calculator.ps1, starts the calculator program
open-email-client.ps1, starts the default email client
open-file-explorer.ps1, starts the Microsoft File Explorer
play-beep.ps1, plays a beep sound
play-files.ps1, plays the given audio files
play-mission-impossible.ps1, plays the Mission Impossible theme
play-m3u.ps1, plays the given playlist (M3U file format)
play-mp3.ps1, plays the given sound file (MP3 file format)

1 Script Description
134 open-email-client.ps1 starts the default email client
135 open-file-explorer.ps1 starts the Microsoft File Explorer
136 play-beep.ps1 plays a beep sound
137 play-files.ps1 plays the given audio files
138 play-mission-impossible.ps1 plays the Mission Impossible theme
139 play-m3u.ps1 plays the given playlist (M3U file format)
140 play-mp3.ps1 plays the given sound file (MP3 file format)

View File

@ -10,6 +10,7 @@ Mega Collection of PowerShell Scripts
* [convert-txt2wav.ps1](Scripts/convert-txt2wav.ps1) - converts text to a .WAV audio file
* [mute-audio.ps1](Scripts/mute-audio.ps1) - mutes audio
* [play-beep.ps1](Scripts/play-beep.ps1) - plays a beep sound
* [play-files.ps1](Scripts/play-files.ps1) - plays the given audio files
* [play-mission-impossible.ps1](Scripts/play-mission-impossible.ps1) - plays the Mission Impossible theme
* [play-m3u.ps1](Scripts/play-m3u.ps1) - plays the given playlist (M3U file format)
* [play-mp3.ps1](Scripts/play-mp3.ps1) - plays the given sound file (MP3 file format)

24
Scripts/play-files.ps1 Executable file
View File

@ -0,0 +1,24 @@
<#
.SYNTAX play-files.ps1 [<file(s)>]
.DESCRIPTION plays the given audio files (supporting MP3 and WAV format)
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
param($Files = "*")
try {
foreach ($File in (get-childItem -path "$Files" -attributes !Directory)) {
if ("$File" -like "*.mp3") {
& "$PSScriptRoot/play-mp3.ps1" "$File"
} else if ("$File" -like "*.wav") {
& "$PSScriptRoot/play-mp3.ps1" "$File"
} else {
"Skipping $File ..."
}
}
exit 0
} catch {
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}