Trying to modify a collection of files and directories can be time consuming. Here is a batch file that will do the work for you. Specify the path and/or files (this examples specifies all files and directories in the current location) and change the called function to do the specified work. Will even handle spaces in the file or directory names.

If you need to pipe or redirect the output, use the escape character (^)

1
2
3
4
5
6
7
8
9
10
11
12
@ECHO OFF
SETLOCAL
 
FOR /f "usebackq delims=:" %%F IN (`dir /b "*.*"`) DO (CALL :doWork "%%F")
GOTO :EOF
 
:doWork
    ECHO Working on %1
    GOTO :EOF
 
:EOF
ENDLOCAL

Reference:
FOR /F

Leave a Reply

You must be logged in to post a comment.