1

I have written a script to search for .avi or .mkv files within a certain directory. Once found I launch a program that processes them and renames them. I am looking to find out how to modify the below script to also search sub folders.

For example. If I have test.avi or test.avi within Downloads the below works fine but if I have test.avi or test.mkv within Downloads/Test it does not work.

cd C:\Users\Administrator\Downloads
for %%X in (*.avi) do start "C:\Program Files (x86)\Rename\Rename.exe" %%X
for %%Y in (*.mkv) do start "C:\Program Files (x86)\Rename\Rename.exe" %%Y

Thanks.

1
  • Why don't you look at the FOR help (type HELP FOR or FOR /? from the command prompt). The answer will be staring at you in the face. Or a simple google search should yield lots of examples.
    – dbenham
    Sep 29, 2013 at 0:24

1 Answer 1

1

/r is a recursive switch. "" is needed in the start command when other quoted strings exist. /w pauses until the completion of each command. The "%%X" quotes allows for spaces etc in the names and paths.

cd C:\Users\Administrator\Downloads
for /r %%X in (*.avi) do start "" /w "C:\Program Files (x86)\Rename\Rename.exe" "%%X"
for /r %%Y in (*.mkv) do start "" /w "C:\Program Files (x86)\Rename\Rename.exe" "%%Y"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.