Batch sequentially process list.txt

March 21, 2011 at 16:29:23
Specs: Windows 7
Hi. I want my file selection to be written to a file list.txt which then shall be processed one by one.

I got a bat to write the selection to list.txt which looks like this:

SETLOCAL EnableDELAYedeXpansion
:Loop
IF "%1"=="" GOTO Continue
dir /s /b %1 >> "C:\Program Files (x86)\converter\list.txt"
SHIFT
GOTO Loop
:Continue

The content of the list.txt looks like this:
D:\Downloads\video1.flv
D:\Downloads\video2.flv
D:\Downloads\video3.flv

How can I feed each line into a file called convert.bat which looks like this:
"C:\Program Files (x86)\converter\converter.exe" %1

The convert.bat obviously needs the first line from list.txt as parameter %1
After converting video1.flv it should continue with the next line until list.txt is finished.


See More: Batch sequentially process list.txt

Report •

#1
March 21, 2011 at 19:28:24
Ok so what i got now is partially working.

Passing selection to write.bat which lists them inside input.txt

setlocal enabledelayedexpansion
:Loop
IF %1=="" goto continue
dir /s /b %1 >> "C:\Program Files (x86)\converter\INPUT.TXT"
SHIFT
GOTO Loop
:continue
CALL convert.bat

Unfortunately the CALL convert.bat does not start. Starting convert.bat manually processes the files in INPUT.TXT

@ECHO OFF
for /f "tokens=1" %%i in (INPUT.TXT) do call :userinput %%i
goto :eof
:userinput
@ECHO OFF
set SIZE=
SET FILESIZE=%~z1
SET FILENAME=%~n1
Set CURRENTDIR=%CD%
SET /a MBSIZE=(%FILESIZE%/1000000)
ECHO Das Video ist momentan %MBSIZE% MB gross.
set /P X= [1] FFMPEG [2] x264 :
if /I "%X%"=="1" SET ENC=ffmpeg
if /I "%X%"=="2" SET ENC=x264
:encode
"C:\Program Files (x86)\converter\converter.exe" -i %1 -o "C:\%FILENAME%_con.mp4" -e %ENC% -2 -T -S %FILESIZE% -E lame -B 128 -R 44.1

Why wont write.bat do the CALL on convert.bat ?


Report •
Related Solutions


Ask Question