Feb 08 2022 01:38 PM
I am a complete newcomer to powershell. I’m not sure if this is the proper forum for powershell novices who are not IT professionals to get help, but I’m giving it a try.
I’m trying to build a script that will cycle through all my flac format music files and check their integrity using the executable program flac.exe. I’ve a good idea how to do this, but I’m having problems calling flac.exe from within a powershell loop. I can execute flac.exe fine if not within a loop.
Specifically, this set of commands works fine:
--------code that works----------
$xdir = “e:\checking_music_collection_for_errors\10_000_Maniacs\(1993)_Mtv_Unplugged\”
Set-Location $xdir “
flac –t good.flac
----------------------------
But if I loop through all the flac files in $xdir and pass them to flac.exe, as in the code directly below, the “-t” option in the flac command (which instructs the program to test the file and not re-encode it) is not understood and is ignored. Because the option is ignored, the flac program thinks I want to re-encode the file but doesn’t because the flac file already exists. The filename is properly passed to the flac program.
--------code that does not work----------------
$xdir = “e:\checking_music_collection_for_errors\10_000_Maniacs\(1993)_Mtv_Unplugged\”
$files = Get-ChildItem $xdir *.flac -recurse
foreach ($f in $files){
echo = $f.FullName
flac –t $f.FullName
}
--------------------
Any help would be greatly appreciated. Thanks.
Feb 08 2022 01:43 PM
Feb 08 2022 01:48 PM
Solution@rm1954
You could try setting the argument (-t) as a variable, so
$xdir = “e:\checking_music_collection_for_errors\10_000_Maniacs\(1993)_Mtv_Unplugged\”
$files = Get-ChildItem $xdir *.flac -recurse
$parameters="-t"
foreach ($f in $files){
echo = $f.FullName
flac.exe $parameters $f.FullName
}
Feb 08 2022 03:07 PM
Feb 08 2022 03:09 PM
Feb 08 2022 01:48 PM
Solution@rm1954
You could try setting the argument (-t) as a variable, so
$xdir = “e:\checking_music_collection_for_errors\10_000_Maniacs\(1993)_Mtv_Unplugged\”
$files = Get-ChildItem $xdir *.flac -recurse
$parameters="-t"
foreach ($f in $files){
echo = $f.FullName
flac.exe $parameters $f.FullName
}