Windows XP 命令提示符重命名命令用于此任务?

Windows XP 命令提示符重命名命令用于此任务?

Windows XP 命令提示符重命名命令用于此任务?

改名...

file.mp3.0001.mp3  
file.mp3.0002.mp3  
file.mp3.0003.mp3  
file.mp3.0004.mp3  

afile.mp3.0001.mp3  
afile.mp3.0002.mp3  
afile.mp3.0003.mp3  
afile.mp3.0004.mp3  

进而

afile.mp3.0001.mp3  
afile.mp3.0002.mp3  
afile.mp3.0003.mp3  
afile.mp3.0004.mp3  

bbfile.mp3.0001.mp3  
bbfile.mp3.0002.mp3  
bbfile.mp3.0003.mp3  
bbfile.mp3.0004.mp3  

进而

afile.mp3.0001.mp3  
afile.mp3.0002.mp3  
afile.mp3.0003.mp3  
afile.mp3.0004.mp3  

b.bfile.mp3.0001.mp3  
b.bfile.mp3.0002.mp3  
b.bfile.mp3.0003.mp3  
b.bfile.mp3.0004.mp3  

我怎样才能做到这一点?

答案1

只需一个控制台命令即可将“*.mp3”重命名为“bb*.mp3” - 它的功能是:

for /f "delims=" %i in ('dir /b /on /a-d *.mp3') do ren "%i%" "b.b%i"

但如果你想分步进行,就会更加困难,就像我的解决方案一样如何在 Windows 中一次重命名 80,000 个文件- 我根据您的要求对其进行了编辑 :),经过了全面测试,并且它也在子文件夹中进行搜索:

  • 使用以下命令创建批处理文件
  • 将变量参数更改为您想要的
    • 路径:在“”中输入文件的根路径(例如“C:\documents and settings\user\desktop\new folder”
    • numfirstchars2replaceX:在每个 X 步骤中用第一个字符替换一个数字(在您的情况下,numfirstchars2replace1=0,numfirstchars2replace2=1,numfirstchars2replace1=1)
    • str2putX:为每个 X 步骤添加一个字符串作为新文件名的前缀(在您的情况下,str2put1=a、str2put2=bb、str2put3=b。)
  • 在与文件所在位置不同的文件夹中运行它


@echo off

::only to tell user what this bat are doing
echo.1.initializing...

::enable that thing to allow, for example, incremental counter in a for loop :)
echo.- EnableDelayedExpansion
SETLOCAL EnableDelayedExpansion

::variables
echo.- variables
:: - place here the absolute root path of your files
set path="put here absolute path where are the root folder of your files"
set pathbak=%cd%
set numfirstchars2replace1=0
set numfirstchars2replace2=1
set numfirstchars2replace3=1
set str2put1=a
set str2put2=bb
set str2put3=b.

::go to %path% and its driveletter
echo.- entering the path you want
for /f "delims=" %%i in ('echo.%path%') do %%~di
cd %path%

::search all subfolders and save them to a temp file
echo.- searching for subfolders
echo.%path%>%temp%\tmpvar.txt
for /f "delims=" %%i in ('dir /s /b /on /ad') do echo."%%i">>%temp%\tmpvar.txt

::execute command for root folder and all found subfolders
echo.
echo.2.executing...

echo.- step 1
for /f "delims=" %%i in (%temp%\tmpvar.txt) do (
  cd %%i
  echo.- in folder: %%i
  for /f "delims=" %%j in ('dir /b /on /a-d *.mp3') do (
    set newname=%%j
    set newname=!newname:~%numfirstchars2replace1%,1000!
    echo.- renaming from "%%j" to "%str2put1%!newname!"...
    ren "%%j" "%str2put1%!newname!"
  )
)

echo.- step 2
for /f "delims=" %%i in (%temp%\tmpvar.txt) do (
  cd %%i
  echo.- in folder: %%i
  for /f "delims=" %%j in ('dir /b /on /a-d *.mp3') do (
    set newname=%%j
    set newname=!newname:~%numfirstchars2replace2%,1000!
    echo.- renaming from "%%j" to "%str2put2%!newname!"...
    ren "%%j" "%str2put2%!newname!"
  )
)

echo.- step 3
for /f "delims=" %%i in (%temp%\tmpvar.txt) do (
  cd %%i
  echo.- in folder: %%i
  for /f "delims=" %%j in ('dir /b /on /a-d *.mp3') do (
    set newname=%%j
    set newname=!newname:~%numfirstchars2replace3%,1000!
    echo.- renaming from "%%j" to "%str2put3%!newname!"...
    ren "%%j" "%str2put3%!newname!"
  )
)

echo.
echo.3.exiting...
::return to %pathbak% and its driveletter
for /f "delims=" %%i in ('echo.%pathbak%') do %%~di
cd %pathbak%

@echo on

答案2

我不知道通过 PowerShell 或伊凡视界,虽然是为图像制作的,但也会进行批量重命名。也许可以编写脚本,但我不是 100% 确定。

截屏

答案3

您可能需要更高级的重命名实用程序,例如重命名

相关内容