Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Read a txt line by line in a batch file

Here is my problem. I have a txt file with 100 different video names (examples):

abc.mpg
def.mpg
ghi.mpg
xyz.mpg

I want to process those videos one by one using some commands and put the results into a folder with the same name (without the extension):

command1 abc.mpg
command2 abc.mpg
move results .\abc

My question is how can I perform the above iteration with a for loop within a batch file.

like image 628
Lampis Avatar asked Apr 23 '12 14:04

Lampis


1 Answers

The command is FOR with /F parameter like this

FOR /F %i in (yourFile.txt) DO yourcommand %i

this reads a line at a time from the text file and insert the value into the %i argument Then call the command specified after the DO keyword (the command could be another batch with the copy or move operations required)

like image 175
Steve Avatar answered Oct 07 '22 01:10

Steve