Batch file to execute all files in a folder

sifuhall picture sifuhall · Feb 12, 2012 · Viewed 29.1k times · Source

I need a batch files the launches all files in a given folder (in this case it is c:\macros\day).

I've tried the following, but it doesn't seem to do anything.

for /f %i in ('C:\macros\Day /b') DO command %i

Answer

Adam Liss picture Adam Liss · Feb 12, 2012

This works from my command line:

for /F "usebackq" %%i in (`dir /b C:\macros\Day\`) DO %%i

as does this:

for %%i in (C:\macros\Day\*) do %%i