batch-file - 将带空格的文件名批量输出到不带引号的文件
问题描述
因此,我编写了一个脚本作为批处理文件,它使用 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'
解决方案
推荐阅读
- java - Java - 给初学者的作业。使用模找到可分性并在之后创建一个循环
- java - 使用java的字符串表达式匹配器
- node.js - 如何使用 json 列上的 where 子句检索数据?
- python - 创建引擎对象以连接postgresql数据库时出现Python sqlalchemy错误?
- java - 如何为所有非空值添加双引号,也不在 Spark Java 中的标题上添加双引号
- node.js - 带有redirect()的Node JS在将标头发送到客户端后无法设置标头
- javascript - 如何在Vue中特定组件的范围内定义`setInterval`?
- javascript - 更新使用 append() 方法和 ajax 请求
- python - 如何合并两个 .dat 文件?
- cassandra - 具有一致性级别和复制因子的 Cassandra 如何处理 CAP 定理?