From a378f3ae47a3e90c5d33f9d803156b6200ea4d64 Mon Sep 17 00:00:00 2001 From: Markus Fleschutz Date: Sat, 1 May 2021 09:26:26 +0200 Subject: [PATCH] Add play-files.ps1 --- Data/scripts.csv | 1 + README.md | 1 + Scripts/play-files.ps1 | 24 ++++++++++++++++++++++++ 3 files changed, 26 insertions(+) create mode 100755 Scripts/play-files.ps1 diff --git a/Data/scripts.csv b/Data/scripts.csv index e5ee332c..ff828101 100644 --- a/Data/scripts.csv +++ b/Data/scripts.csv @@ -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) diff --git a/README.md b/README.md index f5f7c001..697e24bc 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/Scripts/play-files.ps1 b/Scripts/play-files.ps1 new file mode 100755 index 00000000..008878ed --- /dev/null +++ b/Scripts/play-files.ps1 @@ -0,0 +1,24 @@ +<# +.SYNTAX play-files.ps1 [] +.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 +}