Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top