Page 1 of 1

Put date in filename

Posted: 05 Jun 2008 23:35
by DANSOUSA
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

Posted: 06 Jun 2008 07:48
by dizze
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.