How to traverse a directory tree, running a command on each file there?

2

Using cmd.exe after a cursory look though of the output of help for:

Command: FOR /R \Music %file IN (*.flac *.wav *.aif) DO C:flac.exe -f -8 %file
Response: %file was unexpected at this time.

Command: FOR /R \Music %file% IN (*.flac *.wav *.aif) DO C:flac.exe -f -8 %file%
Response: %file% was unexpected at this time.

Jacob Stewart

Posted 2019-05-16T00:16:33.953

Reputation: 23

Answers

0

This work for me:

Replace:

"c:\Full_Path_to\Music" to full path to your \Music folder

@C:\Where\FLAC\Are\flac.exe to full path to Flac.exe

for %i in (flac wav aif)do for /f %F in ('where /r "c:\Full_Path_to\Music" "*.%i"')do C:\Where\FLAC\Are\flac.exe -f -8 "%F"

Or, for bat file:

@for %%i in (flac wav aif)do @for /f %%F in ('where /r "c:\Full_Path_to\Music" "*.%%i"')do @C:\Where\FLAC\Are\flac.exe -f -8 "%%F"

It Wasn't Me

Posted 2019-05-16T00:16:33.953

Reputation: 851