【发布时间】:2018-11-22 08:12:06
【问题描述】:
在 Windows 10 Enterprise LTSC 下,我有一个简单的 CMD ff.bat,其中包含:
powershell -Command (Measure-Command {ffmpeg.exe -hide_banner -i %* E:\%~n1.mkv}).ToString
在 CMD 中> ff test.mp4 和 ff "test.mp4" 有效,但无效
ff "E:\Serie.(2009).8x04.episode.FR.LD.WEBRip.x264-LiBERTY.[server.org.ru].mkv"
鉴于 PowerShell 错误是:
Au caractère Ligne:1 : 60 + (Measure-Command {ffmpeg.exe -hide_banner -i Serie.(2009).8x04.episode.FR.LD.WEBRip.x264-LiBERTY.[server.org.ru].mkv ... +
~ Nom de propriété manquant après l'opérateur de référence。 (引用运算符后缺少属性) Au caractère Ligne:1 : 144 + ... .FR.LD.WEBRip.x264-LiBERTY.[server.org.ru].mp4 E:\Serie ... + ~ Nom de propriété manquant après l'opérateur de référence。 + CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException + FullyQualifiedErrorId : MissingPropertyName
我猜问题出在文件名中的.-[]():\ 以及括号和圆括号字符。
请给我正确的语法以使其在 CMD 中工作。
作为奖励,如果可以的话,你可以给我语法让它在 PS 中工作。
请注意,我是 PowerShell 的新手,需要的示例多于建议。
提前致谢,马克。
【问题讨论】:
-
试试
powershell -Command "(Measure-Command {ffmpeg.exe -hide_banner -i %* """E:\%~n1.mkv"""}).ToString" -
@npocmaka 使用这种方法的问题是,您永远不知道
%*中可能包含哪些双引号参数并打破外部双引号。
标签: windows powershell batch-file cmd syntax