Script to automatically move files into dated folders
A lot of my clients use the built-in Windows Backup utility to do nightly file backups. The thing that makes me nervous about that is by default, the Windows Backup util will churn out one big backup file and then keep appending/overwriting it from that point on.
The paranoid guy in me goes, “Well what if one night the backup job gets corrupt and THEN the server immediately croaks and has to be rebuilt from the corrupt backup file? Unlikely, but if it happens, I’m screwed!
So after much Googlin’, I’ve hacked together a little script creates a folder with today’s date, changes to the E:\backup directory where the .bkf file gets stored, and then moves it into the folder with today’s date. That way each night of backups gets its own corresponding folder.
Simply replace E: and cd \backup with drives/directories of your choice, then save the file as name-of-script.bat. I recommend running it a few hours after the nightly backup usually completes, just to be safe.
Set MM=%date:~4,2%
Set DD=%date:~7,2%
Set YYYY=%date:~-4%
E:
cd \backup
MD %MM%-%DD%-%YYYY%
move *.bkf %MM%-%DD%-%YYYY%
This entry was posted on Monday, February 1st, 2010 at 11:40 am and is filed under Technology. You can follow any responses to this entry through the RSS 2.0 feed. You can skip to the end and leave a response. Pinging is currently not allowed.
April 5th, 2010 at 7:30 pm
Search “RoboBasket” in google you will find a application from Easy-to-Use Software which can automatically process your files based on user predefined rules. You can process your files based on name, size, date, mp3 tag, extension and more other attributes. and choose actions from move, copy, rename, delete and more. You can create rules with just drag&drop, no programming or script skills needed.
May 17th, 2010 at 5:45 pm
Hey sounds cool Dan, thanks for the info!
Brian