Date conversion in filename from dd-mm-yyyy to yyyy-mm-dd

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
xforce30164
Posts: 2
Joined: 12 Mar 2011 22:32

Date conversion in filename from dd-mm-yyyy to yyyy-mm-dd

#1 Post by xforce30164 » 12 Mar 2011 22:39

Hi everyone,
I need some help with a batch file im trying to write to mame the renaming of my Podcasts alot easier. I want to do this because in the dd-mm-yyyy format they do not sort properly by name.

The filename buildup is as follows:

"Always the same startpart"[space]dd-mm-yyyy.mp3 and i need it to be renamed to "Always the same start part"[space]yyyymmdd.mp3

All help is appteciated!
Ps. I do have some basic knowledge of batch and already have beennsearching for a bit now and still couldnt find it so i decided to post my question here.

Pps. Please forgive me any spelling mistakes because im kinda tired and its 05:40 here atm ^^.

!k
Expert
Posts: 378
Joined: 17 Oct 2009 08:30
Location: Russia

Re: Date conversion in filename from dd-mm-yyyy to yyyy-mm-d

#2 Post by !k » 13 Mar 2011 02:24

Code: Select all

for /f "delims=" %%a in ('dir /b *.mp3 ^|^
ssed.exe -n -R "s/^(.*\s)(\d\d)-(\d\d)-(\d{4})(\.mp3)$/ren \"\1\2-\3-\4\5\" \"\1\4\3\2\5\"/p"'
) do %%a

ssed.exe: http://sed.sourceforge.net/grabbag/ssed/sed-3.62.zip

xforce30164
Posts: 2
Joined: 12 Mar 2011 22:32

Re: Date conversion in filename from dd-mm-yyyy to yyyy-mm-d

#3 Post by xforce30164 » 13 Mar 2011 05:09

Thank you very very much! That solved my problem :D!

Post Reply