mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-08-19 08:52:05 +02:00
Updated the manuals
This commit is contained in:
@@ -1,15 +1,15 @@
|
||||
The *play-files.ps1* Script
|
||||
===========================
|
||||
|
||||
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).
|
||||
|
||||
Parameters
|
||||
----------
|
||||
```powershell
|
||||
/home/markus/Repos/PowerShell/scripts/play-files.ps1 [[-FilePattern] <String>] [<CommonParameters>]
|
||||
/Repos/PowerShell/scripts/play-files.ps1 [[-filePattern] <String>] [<CommonParameters>]
|
||||
|
||||
-FilePattern <String>
|
||||
Specifies the file pattern
|
||||
-filePattern <String>
|
||||
Specifies the file pattern ('*' by default)
|
||||
|
||||
Required? false
|
||||
Position? 1
|
||||
@@ -25,7 +25,9 @@ Parameters
|
||||
Example
|
||||
-------
|
||||
```powershell
|
||||
PS> ./play-files *.mp3
|
||||
PS> ./play-files.ps1 *.mp3
|
||||
▶️ Playing '01 Sandy beaches - strong waves.mp3' (02:54) ...
|
||||
...
|
||||
|
||||
```
|
||||
|
||||
@@ -42,33 +44,41 @@ Script Content
|
||||
```powershell
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Plays audio files (MP3 and WAV)
|
||||
Plays audio files
|
||||
.DESCRIPTION
|
||||
This PowerShell script plays the given audio files (supporting MP3 and WAV format).
|
||||
.PARAMETER FilePattern
|
||||
Specifies the file pattern
|
||||
This PowerShell script plays the given audio files (supporting .MP3 and .WAV format).
|
||||
.PARAMETER filePattern
|
||||
Specifies the file pattern ('*' by default)
|
||||
.EXAMPLE
|
||||
PS> ./play-files *.mp3
|
||||
PS> ./play-files.ps1 *.mp3
|
||||
▶️ Playing '01 Sandy beaches - strong waves.mp3' (02:54) ...
|
||||
...
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
param([string]$FilePattern = "*")
|
||||
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"
|
||||
$stopWatch = [system.diagnostics.stopwatch]::startNew()
|
||||
|
||||
$files = (Get-ChildItem -path "$filePattern" -attributes !Directory)
|
||||
[int]$count = 0
|
||||
foreach ($file in $files) {
|
||||
if ("$file" -like "*.mp3") {
|
||||
& "$PSScriptRoot/play-mp3.ps1" "$file"
|
||||
$count++
|
||||
} elseif ("$File" -like "*.wav") {
|
||||
& "$PSScriptRoot/play-mp3.ps1" "$File"
|
||||
& "$PSScriptRoot/play-mp3.ps1" "$file"
|
||||
$count++
|
||||
} else {
|
||||
"Skipping $File ..."
|
||||
"Skipping $file (no audio file)..."
|
||||
}
|
||||
}
|
||||
[int]$elapsed = $stopWatch.Elapsed.TotalSeconds
|
||||
"✅ Played $count audio files for $($elapsed)s."
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
@@ -76,4 +86,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 as of 11/20/2024 11:51:59)*
|
||||
*(page generated by convert-ps2md.ps1 as of 01/17/2025 08:30:56)*
|
||||
|
Reference in New Issue
Block a user