mirror of
https://github.com/fleschutz/PowerShell.git
synced 2024-11-28 10:53:32 +01:00
Updated play-files.ps1
This commit is contained in:
parent
de784e4cdc
commit
4f57fbe3b2
@ -1,32 +1,40 @@
|
|||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Plays audio files (MP3 and WAV)
|
Plays audio files
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
This PowerShell script plays the given audio files (supporting MP3 and WAV format).
|
This PowerShell script plays the given audio files (supporting .MP3 and .WAV format).
|
||||||
.PARAMETER FilePattern
|
.PARAMETER filePattern
|
||||||
Specifies the file pattern
|
Specifies the file pattern ('*' by default)
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> ./play-files *.mp3
|
PS> ./play-files.ps1 *.mp3
|
||||||
|
▶️ Playing '01 Sandy beaches - strong waves.mp3' (02:54) ...
|
||||||
|
...
|
||||||
.LINK
|
.LINK
|
||||||
https://github.com/fleschutz/PowerShell
|
https://github.com/fleschutz/PowerShell
|
||||||
.NOTES
|
.NOTES
|
||||||
Author: Markus Fleschutz | License: CC0
|
Author: Markus Fleschutz | License: CC0
|
||||||
#>
|
#>
|
||||||
|
|
||||||
param([string]$FilePattern = "*")
|
param([string]$filePattern = "*")
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$Files = (get-childItem -path "$FilePattern" -attributes !Directory)
|
$stopWatch = [system.diagnostics.stopwatch]::startNew()
|
||||||
"Playing $($Files.Count) files ..."
|
|
||||||
foreach ($File in $Files) {
|
$files = (Get-ChildItem -path "$filePattern" -attributes !Directory)
|
||||||
if ("$File" -like "*.mp3") {
|
[int]$count = 0
|
||||||
& "$PSScriptRoot/play-mp3.ps1" "$File"
|
foreach ($file in $files) {
|
||||||
|
if ("$file" -like "*.mp3") {
|
||||||
|
& "$PSScriptRoot/play-mp3.ps1" "$file"
|
||||||
|
$count++
|
||||||
} elseif ("$File" -like "*.wav") {
|
} elseif ("$File" -like "*.wav") {
|
||||||
& "$PSScriptRoot/play-mp3.ps1" "$File"
|
& "$PSScriptRoot/play-mp3.ps1" "$file"
|
||||||
|
$count++
|
||||||
} else {
|
} else {
|
||||||
"Skipping $File ..."
|
"Skipping $file (no audio file)..."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
[int]$elapsed = $stopWatch.Elapsed.TotalSeconds
|
||||||
|
"✅ Played $count audio files for $($elapsed)s."
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||||
|
Loading…
Reference in New Issue
Block a user