Batch file to run all files in a folder

I need batch files that run all the files in this folder (in this case, c: \ macroros \ day).

I tried the following, but it does nothing.

for /f %i in ('C:\macros\Day /b') DO command %i 
+6
source share
6 answers

This works from my command line:

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

how it does:

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

You used the wrong for option. just do (pun) for %%i in (c:\macros\Day\*) do %%i

Edit: If you need to run command for all files: for %%i in (c:\macros\Day\*) do command %%i

+5
source

You must use dir /b to display all files, so it becomes

 for /f %i in ('dir /bc:\macros\Day') do command %i 
+2
source

Also, make sure that you make the variables inside the batch files %% i, not% i, otherwise you get an error like "I was unexpected at the time."

0
source

Run all files in a directory through a batch file with added text on each line

The alternative is laid out above - leave unchanged "/ Z / U" if you want.

0
source

Here is how I could run all powershell files in the same directory as the batch file

 @ECHO OFF SET PowerShellExe=%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\powershell.exe for %%i in (*.ps1) do ( %PowerShellExe% -NoProfile -ExecutionPolicy Bypass -Command %cd%\%%i ) 
0
source

Source: https://habr.com/ru/post/908268/


All Articles