输出文件名,并在文件中带有空格,但不批量添加引号

问题描述 投票:0回答:1

因此,我编写了一个脚本作为批处理文件,该脚本使用FFmpeg在硬盘上“合并”了多个视频文件。脚本如下。

@echo off
title Printing video info...
(for %%i in (
"%USERPROFILE%"/Dropbox/Video1.MKV
"%USERPROFILE%"/Dropbox/Video2.MKV
S:/Exports/Video3.MKV
../../video/Video4.mkv
) do ( if exist "%%i" echo file '%%i' )) > "%~n0.txt"
type "%~n0.txt"
title Copying to compiled video...
"C:\Program Files\ffmpeg\bin\ffmpeg.exe" -hide_banner -f concat^
                  -safe 0 -y -i "%~n0.txt" -c copy "%~n0.mkv"

这里的问题是计算机上的用户名名称中有空格,因此脚本不起作用。如果我用%USERPROFILE%加上引号,则批处理脚本会检测到该文件,但是批处理脚本也会将引号放入输出TXT文件中,这会导致FFmpeg命中该文件时失败。

脚本输出到的文本文件的内容应为:

file 'C:\Users\Name/Dropbox/Video1.MKV'
file 'C:\Users\Name/Dropbox/Video2.MKV'
file 'S:/Exports/Video3.MKV'
file '../../video/Video4.mkv'
batch-file ffmpeg
1个回答
1
投票
© www.soinside.com 2019 - 2024. All rights reserved.