Hi. I have a folder of .pdf files I’d like to rename using a batch file. Each filename consists of three words separated by an underscore:
first_second_third.pdf
Would like to rename with this result:
third_second_first.pdf
Am still pretty new at batch file programming and appreciate the help!
@echo off & setlocal
for /f “tokens=1-3 delims=_” %%a in (‘dir /b *.pdf’) do echo ren “%%_%%b_%%c.pdf” “%%c_%%b_%%a.pdf”
::— end
i left the safety “on” (echo). If satisfied, just remove the “echo” from the command-string.
Assuming none of the filenames contains a dot (other than the extension), the dot would be the easiest way:
for /f “tokens=1-3 delims=_.” %%a in (‘dir /b *.pdf’) do echo ren “%%a_%%b_%%c.pdf” “%%c_%%b_%%a.pdf”