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

I would like to create a batch file that

A) Reads all files in the current directory

B) Writes all files in the current directory to another batch file

C) Adds text to each line (I want to add "/ Z / U" (for silent and nostarton respectively)

What I still have:

FILE BATCH

@echo on @setlocal enableextensions @cd /d "%~dp0" dir /b > installALLTHETHINGS.bat echo /Z /U >> installALLTHETHINGS.bat 

The output of the batch file is here:

OUTPUT

 exe1.exe bat1.bat installme.msi bat2.bat bat3.bat file list.bat /Z /U 

I am sure I can understand how to get "/ Z / U" in this last line without creating a new line, but is there any way to write "/ Z / U" after every file in the directory

0
source share
1 answer

I can’t understand why you want to do this, but it is just done using the FOR loop.

 @echo off cd /d "%~dp0" >installAllTheThings.bat ( for %%F in (*) do if "%%F" neq "installAllTheThings.bat" if "%%F" neq "%~nx0" echo "%%F" /Z /U ) 
0
source

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


All Articles