Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows console - BAT compatibility

I have a command line statement which works perfectly when manually typing it into the console, however, when I put it in a bat file it doesn't work.

for %f in (*.flac) do ffmpeg -i "%f" -acodec alac "%~nf.m4a"

Here is the error message when I try running the bat file

The following usage of the path operator in batch-parameter
substitution is invalid: %~nf.m4a"

Is there any way to fix this? The statement converts flac files to alac files using the program ffmpeg.

like image 439
Michael Avatar asked Aug 02 '26 10:08

Michael


1 Answers

When batch files are interpreted %% is replaced with %, so your solution would be to replace %f with %%f

like image 91
ImplexOne Avatar answered Aug 04 '26 07:08

ImplexOne



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!