windows batch file rename

后端 未结 6 1013
别跟我提以往
别跟我提以往 2020-12-09 16:54

I have some file such as AAA_a001.jpg, BBB_a002.jpg, CCC_a003.jpg in Windows 7 and I\'m trying to use batch to rename these file to

6条回答
  •  南笙
    南笙 (楼主)
    2020-12-09 17:15

    @echo off
    pushd "pathToYourFolder" || exit /b
    for /f "eol=: delims=" %%F in ('dir /b /a-d *_*.jpg') do (
      for /f "tokens=1* eol=_ delims=_" %%A in ("%%~nF") do ren "%%F" "%%~nB_%%A%%~xF"
    )
    popd
    

    Note: The name is split at the first occurrence of _. If a file is named "part1_part2_part3.jpg", then it will be renamed to "part2_part3_part1.jpg"

提交回复
热议问题