Batch script to invert the order of a date in file names

后端 未结 1 1300
名媛妹妹
名媛妹妹 2021-01-28 12:30

I wanted to use a batch script to rename a bunch of files which are using the following name scheme:

File 2-9.pdf
File 3-9.pdf
File 4-9.pdf
[...]
相关标签:
1条回答
  • relatively easy. Don't use "search and replace", but use proper tokens and delimiters to split your filenames:

    @echo off 
    for %%f in (*.pdf) do (
      for /f "tokens=1,2,3 delims=- " %%a in ("%%~nf") do (
        ECHO ren "%%~f" "%%a %%c-%%b%%~xf"
      )
    )
    

    (Note: remove the ECHO after troubleshooting to enable the rename command)

    0 讨论(0)
提交回复
热议问题