How to Automatically create folders named by Date
Had an interesting scenario with an old Line of Business application for a client yesterday.
It was an old system that relied on Floppy Disks for Backups. The client was aware (due to my constant nagging!) that Floppy Disks weren’t to be trusted as a backup medium, and so had purchased a couple of USB Key-Disks to store the backups onto instead.
Fooling the system into thinking a USB disk was a Floppy was fairly simple, but where the system fell over was in the fact it didn’t overwrite the last backup… it simply threw a hissy-fit and crashed out!
Obviously, the client could manually delete the previous backup – but I looked for an automated solution.
The result? A small batch file that creates a folder within a sub-folder with that days date, with the batch-file set to “autorun” each and every time the USB Key Disk is inserted for the clients convenience.
Batch File:-
set dd=%date:~0,2%
set mm=%date:~3,2%
set yyyy=%date:~6,4%
mkdir “PayrollBackup%yyyy%-%mm%-%dd%”
move pay-data* “Backup%yyyy%-%mm%-%dd%”
Autorun File:-
[autorun]
open=Update.bat
action=Ready USB Disk for Backup
label=Backup
I don’t get many chances to write scripts nowadays, even very basic ones, so this was a good chance for me to get geeky. 🙂
Comments
2 thoughts on How to Automatically create folders named by Date
PAUL
4TH NOVEMBER 2008 14:53:30
Thanks for this, I adapated it to do something slighty different but your batch file gave me what I needed. Thank you!
RICHARD
5TH NOVEMBER 2008 10:08:22
Paul - you're welcome, and glad you found it of use!