繁体   English   中英

为什么这个 REN 命令返回“命令的语法不正确”?

[英]Why does this REN command return “The syntax of the command is incorrect”?

我在一个文件夹中有一些文件,例如:

  1. 快乐之歌.m4a.mp3
  2. 悲伤的歌曲 ft. HER.m4a.mp3

我想将这些重命名为:

  1. 快乐之歌.mp3
  2. 悲伤的歌曲 ft. HER.mp3

这是我放置在同一文件夹中的test.bat文件的代码:

for /f "delims=" %%a in ('dir  /b /a-d *.m4a.mp3') do (
  set "oldName=%%~a"
  set "newName=%oldName:.m4a=%"
  ren %%a "%newName%"
)

它返回The syntax of the command is incorrect.
我试过了:

for /f "delims=" %%a in ('dir  /b /a-d *.m4a.mp3') do (
  set "oldName=%%~a"
  set "newName=%oldName:.m4a=%"
  ren %%a %newName%
)

返回ft. was unexpected at this time.
我在这里做错了什么?

您可能可以从这样做:

For %G In (*.m4a.mp3) Do @For %H In ("%~nG") Do @Ren "%G" "%~nH%~xG"

或者像这样来自

@For %%G In (*.m4a.mp3) Do @For %%H In ("%%~nG") Do @Ren "%%G" "%%~nH%%~xG"

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM