Reputation: 12005
I tried to get all file names in directory input
but it does not work for me.
@echo off
:start
cls
FOR /D %%i IN ("input*") DO python index.py %%i
TIMEOUT /T 20
exit
Upvotes: 0
Views: 73
Reputation: 16226
If you want all file names (not directory names) in the input
directory, use the following. It will produce all file names that are not directories and run the python command on them. Always quote path names in case there are spaces or other special characters in them.
FOR /F %%i IN ('DIR /B /A:-D "input"') DO (
"C:\venv\py36-64\Scripts\python.exe" "C:\path\to\index.py" "%%~i"
)
If the python.exe
directory is in the PATH variable and index.py
is always in the parent directory of input
, then you could use this.
FOR /F %%i IN ('DIR /B /A:-D "input"') DO (
"python.exe" "..\index.py" "%%~i"
)
Upvotes: 1