Rename file using date


I need this code so that my log file is not getting bigger and bigger each time and I can manage my logfile per day. This is the windows command to rename a file to use a date format:

ren test.txt test_%date:~10%-%date:~4,2%-%date:~7,2%.txt

The command will rename the file to test_2010-04-30.txt

To add the TIME format:

ren test.txt test_%date:~4,2%-%date:~7,2%-%date:~10,4%_%time:~0,2%.%time:~3,2%.txt

The command will rename the file to test_2010-04-30_16.21.txt

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: