Sunday, October 28, 2007

Rename a File in Batch File

The Following helps in renaming a file using datatime stamp

// you are creating date stamp variable

FOR /F "tokens=1-4 delims=/ " %%i in ('date/t') do set d=%%k%%j%%l

// you are creating Time stamp variable

FOR /F "tokens=1-9 delims=:. " %%i in ('time/t') do set t=%%i%%j
// Here Renaming

ren abcd.doc new_%d%%t%.doc