Вопрос

I have a list of files to convert like this

C:\Users\jtl999\foo_001.jpg
C:\Users\jtl999\foo_002.jpg

To convert them manually I invoke the converter like this

convert_files.bat C:\Users\jtl999\foo_001.jpg

Basically what I want to do is read through the list of files one at a time and pass the file as a argument. On Linux I could use find and xargs but I am on Windows 7.

Это было полезно?

Решение

for %f in ("c:\users\jtl999\foo_*.jpg") do call convert_files.bat "%~ff"

For each file in the indicated set, call the batch file, passing as a parameter the full path to the file

The syntax is for usage from command line. To use this in a batch file: Change the parameters of for command so that the percent sign is doubled. %f should be %%f and %~f should be %%~f

Другие советы

for /f %i in ('dir /b /s "C:\Users\jtl999\foo_*.jpg"') do call convert_files.bat "%i"

use %%i instead of %i in batch-files.

You need the parameter /s to get the full path. Although this means, you will also get any files in sub directories that fits your filter (if there are some).

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top