代码可以在 Windows 命令行中运行,但不能在 Power Shell 中运行

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

这里是 Windows 11。

尝试使用

.mp4
 将文件夹中的所有文件(都是 
.mp3
 文件)转换为 
FFMPEG

文件

我从https://ottverse.com/convert-all-files-inside-folder-ffmpeg-batch-convert/#Convert_all_the_audio_files_WAV_MP3_OGG_in_your_folder_to_MP3_format

获取了代码

我目前位于

E:\Downloads2\
文件夹

使用 Windows 命令行 (CMD)时,以下代码有效:

for %f in (*.*) do "C:\FFMPEG\ffmpeg" -i "%f" -vn -acodec libmp3lame -q:a 2 "E:\Downloads2\converted\%~nf.mp3"

但是,当我在 Power Shell 中尝试它时(前面附加了

./
),我收到以下错误消息:

*.* : The term '*.*' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

为什么它在 Power Shell 中不起作用?

powershell command-line
1个回答
0
投票

显然这是两种不同的语言。 从 powershell 调用 cmd:

cmd /c 'for %f in (*.*) do "C:\FFMPEG\ffmpeg" -i "%f" -vn -acodec libmp3lame -q:a 2 "E:\Downloads2\converted\%~nf.mp3"'

Powershell 会是这样的:

get-childitem *.* | foreach-object { 
C:\FFMPEG\ffmpeg -i $_ -vn -acodec libmp3lame -q:a 2 "E:\Downloads2\converted\$($_.basename + '.mp3')" }
© www.soinside.com 2019 - 2024. All rights reserved.