|
Answer» I have a script to execute a custom program (an executable) with static filename as a parameter. I need to extend this to ITERATE and execute for all files in any given directory.
I saw commands to use % and use Variables.
- How do I create a loop (perhaps USING a GoTo and Label)? - How do I read retrieve the files from the directory - ONE at a time until all the files are read?
I'd appreciate any help.
Thanks.you can use a combination of dir command and for loop. The for loop are indispensable in batch. if you type dir /? and for /? you can see how they can be used. For example Code: [Select]dir /A-D /B This dir command with /A-D /B OPTION says to list files and not directories , in bare format. Then u can use for loop like this
Code: [Select]@echo off for /F %%i in ('dir /A-D /B') do ( executefile %%i ) where executefile is your program that takes in a parameter that is a file name. Please take time to read dir /? and for /? to gain better understanding.
|