Hi everyone!
I would like to ask how can I create a batch file that inputs data from a text file? Say, I create a batch file with the command "del", and I want it to delete all the files listed in a text file.
My Text file:
1.jpg
2.jpg
3.jpg
How can I make the batch file delete all these files?
I know you can do it this way:
@echo off
set /p Test=<text.txt
del %Test%
However, how do I do it for multiple lines in a text file?
Thank you!
Text files as input to batch command
Moderator: DosItHelp
rabbit123,
Use FOR loop:
Note, the "ECHO" is for testing.
DosItHelp?
Use FOR loop:
Code: Select all
@echo off
for /f "tokens=*" %%A in (text.txt) do ECHO del %%A
Note, the "ECHO" is for testing.
DosItHelp?