I am by skill set not a programmer, but would greatly appreciate any help on creating a batch file. I have multiple PDF's in a folder and need to change the order of the file name. For example, the existing file is Monthly_Statement_07_2014_12345678.PDF, and need to reorder / change the name to 2014_07_12345678_Monthly_Statement.PDF. After a few Google searches I developed this script, but it doesn't appear to do anything.
@echo off & setlocal
for /f "tokens=1-5 delims=_" %%a in (*.pdf) do echo ren "%%a_%%b_%%c_%%d_%%e.pdf" "%%d_%%c_%%e_%%a_%%b.pdf"
::--- end
I created the file in Notepad and saved it as a .BAT. I am also running Windows 8.1 if that is a factor.
Thanks in advance.
Daniel
Batch command to reorder file name
Moderator: DosItHelp
Re: Batch command to reorder file name
Code: Select all
@echo off & setlocal
for /f "tokens=1-5 delims=_" %%a in ('dir /a-d /b *.pdf') do echo ren "%%a_%%b_%%c_%%d_%%~ne.pdf" "%%d_%%c_%%~ne_%%a_%%b.pdf"
remove the ECHO when the output looks correct.
Re: Batch command to reorder file name
Thank you! Your script work perfectly.