DOS: Create a directory according to the date. How

Status
Not open for further replies.

casanova

The Frozen Nova
Can someone help me in creating a bat file.

Intended task
1. On my desktop there are many text files for which I need to make a backup
2. In D drive it should create a folder Back if it does not exist
3. I plan to run this file everyday, so it should create a subdirectory in the Directory back that is for the current day
4. Copy the text files to the subdirectory according to todays date

D:\Backup\Yesterday
D:\Backup\Today
D:\Backup\Tomorrow

Needless to say, yesterday, today and tomorrow would be the respective dates
 

din

Tribal Boy
May be you need this ?

DateDir: A Date-Naming Utility for Windows

This may be useful too
 
Last edited:
OP
casanova

casanova

The Frozen Nova
Din, Thx for the link, however it has issues when a limited permission user tries to run it. Also, we can't run these apps in my office. So, I need to do it manually.

Even, if some1 guides me how to make a directory for today's date, it will help me a lot.
 

din

Tribal Boy
Oh, I am sorry it didn't help

But theres something about the batch files in both links ? May be thats useful ?
 
OP
casanova

casanova

The Frozen Nova
Thx a ton Din. Second link helped me. I achieved what I wanted to do. Thx again.

Here's the file
d:
cd backup_kb
md TEXT_%Date:~-4,4%%Date:~-10,2%%Date:~-7,2%
c:
cd..
cd desktop
copy *.txt d:\backup_kb\TEXT_%Date:~-4,4%%Date:~-10,2%%Date:~-7,2%
pause

It created the dir TEXT_20070913 ie. yyyymmdd format
 
Status
Not open for further replies.
Top Bottom