簡體   English   中英

Windows批處理文件:對於/ F,只讀mylist.txt的第一行,然后刪除第一行

[英]Windows Batch File: for /F read only first line of mylist.txt and delete first line afterwards

我運行一個批處理腳本:

FOR /F "tokens=1" %%F IN (mylist.txt) do C:\VideoConverter\Applications\ffmpeg.exe ^
-f image2 -loop 1 -framerate 0.1 -i "%%~F" -i "%~dpn1.mp3" -codec:v libx264 ^
-s 1920x1080 -acodec copy -strict experimental -movflags faststart -t 00:10:10.00 ^
-f mp4 "%~dpn1.mp4"

我的文件夾中有以下文件:

file001.mp3
file002.mp3
file003.mp3

mylist.txt包含:

pic001.jpg 
pic002.jpg 
pic003.jpg

目前,腳本為文件夾中的每個mp3創建了3個具有3個不同背景圖片的視頻。 錯了

我只想創建這三個視頻。

video 1 = file001.mp3 + pic001.jpg (line1) 
video 2 = file002.mp3 + pic002.jpg (line2)
video 3 = file003.mp3 + pic003.jpg (line3)

有人可以通過for /f命令幫助我嗎? 謝謝您的幫助。

我將使用for循環播放視頻,並通過stdin(帶有< )將mylist.txt推送到for循環中,然后讓set /p逐行捕獲(每次循環迭代一次)。 像這樣:

@echo off & setlocal

(
    for %%I in (*.mp3) do (

        rem // set /P grabs one line of input from stdin
        set /P "imagefile="

        setlocal enabledelayedexpansion
        if defined imagefile call :build "%%~I" "!imagefile!" "%%~dpnI.mp4"
        endlocal

        set "imagefile="
    )
) < mylist.txt
rem // The line above dumps mylist.txt into stdin, letting set /P grab one line at a time.

goto :EOF

:build <in_mp3> <in_image> <outfile>
C:\VideoConverter\Applications\ffmpeg.exe -f image2 -loop 1 -framerate 0.1 ^
-i "%~1" -i "%~2" -codec:v libx264 -s 1920x1080 -acodec copy -strict experimental ^
-movflags faststart -t 00:10:10.00 -f mp4 "%~3"

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM