0

I'm trying to pass files one by one(I have to dot that since executable only accepts one file at a time). So, in my batch I have follwoing:

FOR /F %file IN ('dir /b /s *.css') DO CALL myExecutable.exe %file 

I should see out files in same directory but nothing happens, no errors are displayed either. Am I missing something here?

dev.e.loper
  • 35,446
  • 76
  • 161
  • 247

1 Answers1

1

You have several mistakes in your example:

  • FOR parameter name is a single letter only
  • CALL is used to call another batch file or a subroutine in the existing batch file, not executables
  • the FOR parameter should be referenced with two %, when in batch file
  • you need to use a non-space delimiter, if the directory you run this command in or any subdirectory, or if any of the files has a space in the name

With these in mind, here's the right command you should be using:

for /f "usebackq delims=|" %%f in (`dir /b /s *.css`) do myexecutable.exe "%%f"

Here's my answer to a similar SO question, where I give more details on using FOR to process all files in a directory.

Community
  • 1
  • 1
Franci Penov
  • 74,861
  • 18
  • 132
  • 169
  • technically, you don't need the `usebackq` in your particular scenario, but it's a good habit to have. – Franci Penov Aug 11 '10 at 20:37
  • thank you this made it work. except that I had to exclude "usebackq delims=|". it didn't work, it started to process 'dir' 'b' as actual file names. once it was removed, everything works. – dev.e.loper Aug 11 '10 at 20:47