whtkj
whtkj

Reputation: 25

How to do an operation on each file in a directory with a batch script

How do you iterate over each file in a directory with a .bat or .cmd file and run an .exe on the files. So far I've got:

    set /p UserInputPath=Set directory files to compress 
    cd /D "path to my compressMDF4video.exe"

    forfiles /p "%UserInputPath%" /c "compressMDF4video.exe"

    PAUSE

But I get an error: Can't find specified file for each of the files What is the problem here?

Upvotes: 1

Views: 117

Answers (1)

Gurhan Polat
Gurhan Polat

Reputation: 706

You can use for command.

for /R C:\ %%a in (*) do echo %%a

change C:\ with your dir, and echo with your executable file.

Upvotes: 2

Related Questions