在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错误是:
至字符行:1:60 +(Measure-Command {ffmpeg.exe -hide_banner -i Series。(2009).8x04.episode.FR.LD.WEBRip.x264-LiBERTY。[Server.org.ru] .mkv。 .. + 〜引用运算符后缺少属性名称。 (引用运算符后缺少属性)到行字符:1:144 + ... .FR.LD.WEBRip.x264-LiBERTY。[Server.org.ru] .mp4 E:\ Serie ... +〜Property Name参考运算符后丢失。 + CategoryInfo:ParserError:(:) [],ParentContainsErrorRecordException + FullyQualifiedErrorId:MissingPropertyName
我想问题来自.-[]():\
和文件名中的括号和括号字符。请问你能给我正确的语法,以便在CMD中工作。作为奖励,你可以给我一些语法,让它在PS中工作,如果可以的话。请注意我在PowerShell中是一个完整的新手,需要的例子不仅仅是建议。提前谢谢,马克。
你的假设......
我想这个问题来自文件名中的.-:\和括号和括号字符
...是正确的。
每种语言用例都有特殊字符。它们只能按语言规范中的定义使用。如果您使用的任何字符串具有这些类型的字符,您需要删除它们或正确终止它们。
<#
LONG DESCRIPTION
Windows PowerShell supports a set of special character sequences that
are used to represent characters that are not part of the standard
character set.
The special characters in Windows PowerShell begin with the backtick
character, also known as the grave accent (ASCII 96).
The following special characters are recognized by Windows PowerShell:
`0 Null
`a Alert
`b Backspace
`f Form feed
`n New line
`r Carriage return
`t Horizontal tab
`v Vertical tab
--% Stop parsing
#>
Get-help -Name about_Special_Characters
括号,括号,括号也有特殊含义,不能用于文件名。
PowerShell - Special Characters And Tokens
因此,通过您在失败的文件名中显示的内容,您需要重命名这些文件名。