BraimeeDotCom

Movie reviews. Tech tips. Bad parenting.

Flower

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%

2 Responses to “Script to automatically move files into dated folders”

  1. April 5th, 2010 at 7:30 pm

    Dan says:

    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.

  2. May 17th, 2010 at 5:45 pm

    Brian says:

    Hey sounds cool Dan, thanks for the info!

    Brian

Leave a Reply