Put date in filename

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
DANSOUSA
Posts: 1
Joined: 02 Mar 2008 19:28

Put date in filename

#1 Post by DANSOUSA » 05 Jun 2008 23:35

Hello,

I need to rename some files daily to be imported to our system. I need to append the file creation date just before the actual name in the format YYYY MM DD and a dash so the filename become YYYY MM DD - actualFileName.txt

Can anyone help me with this?

Thanks
Daniel

dizze
Posts: 10
Joined: 12 Jul 2006 07:53
Contact:

#2 Post by dizze » 06 Jun 2008 07:48

hey,

Something like:

Code: Select all

@echo off
for /f "tokens=1,2,3 delims=/" %%a in ('echo %date%') do set foo=%%c %%b %%a
for %%a in (*.*) do ren "%%a" "%foo% - %%a"


Would append the date to the start of all files in the dir it is executed in.

Post Reply