Automated File Moving
I had what seemed on its surface to be a simple problem, and turned out to be simple in the end. I have a couple of motion-detecting security cameras that record video. They came with software that synchronized to the internet, essentially running the PC as a server. This broke about a year ago, when I replaced a router, and when I reconfigured it to the right state (it requires the PC to have a fixed internal IP address) the system that let me view the images no longer worked. Or maybe it does and the router remains misconfigured -- this is very hard to diagnose when all you get is "unable to connect".
In any case, I had the bright idea of using SugarSync to upload the recorded video files. SugarSync is really easy and doesn't require configuring a home server. So I created an instance of SugarSync solely for this PC, point it at the internet, and voila!
(If you have several computers and don't use SugarSync, I highly recommend it. For me it keeps different folders on my five frequently used computers synced, and I no longer carry a USB key to do this. But a warning: SugarSync is not a backup solution. It lets you recover from accidentally deleted files. But if you accidently overwrite a file on one PC, that file will be synced to the others and the original is now gone.)
Only it isn't quite that easy. SugarSync gives a generous 5GB free, but that is about a two months of security cam video. That is OK with me -- I only want to see security cam video on the web when I'm traveling, and storing a month's video is fine. A complete solution is to sync the video folders, but use a script to move video older than a month to another folder that isn't synced.
Sounds simple, right?
I tried two solutions: use a vbs (visual basic scripting) script from the web and Cyber-D's Autodelete. And then I tried a third solution which worked.
There are a bunch of vbs scripts available on the web that purport solve exactly this problem. A bit of a challenge is that I want to preserve the file structure when I move the files, which narrows the field, but I found several scripts that allegedly did this. I set up two folders to test with and tried configuring a script I found on the web, which sometimes worked and sometimes didn't. I found myself looking inside the script, changing date last modified to date created, and generally spending a lot of time on a problem which someone must have already solved, right? So I looked for a commercial solution.
Enter Cyber-D's Autodelete. This ought to be exactly the thing, and all it asks is a donation. It is easy to configure with a graphical interface and offers a fine solution, but it had a bug when I used it. If I set it to delete files at least 28 days old, it deleted those just fine, but it also deleted files that were less than 12 hours old. I tried a bunch of things, and the creator even sent me a logging file (which wouldn't run on my old Windows XP SP3 machine I use for this purpose).
I spent a fair bit of time trying to make this work (weirdly, when asked to move files from multiple folders it misfired on all but the last folder, unless there was only one).
Then I found waRmZip on SourceForge. Ignore the funny name, it worked great!
The code I used is
c:waRmZip.wsf /r c:\Location1 /ma:28 /md:c:\Location2\$YEAR /q
Here, I've put the program waRmZip.wsf in my c: drive. The control /r means "process subfolders." The program grabs the files from c:\Location1 (put whatever you want here but don't have a trailing slash). /ma:28 means "move files older than 28 days, and /md:c:\Location2\$YEAR means "put those files in c:\Location2\the current year followed by the file structure. So if the original files were in c:\videocam\webcam1, and Location2 was set to videobackup\webcam1, the files would appear in c:\videobackup\webcam1\2011 (or whatever the current year is when you read this). Finally /q means to run quietly without user input, so that it can be automated.
To automate the process, you just copy that command into a text file with a .bat extension, like filemover.bat. You can put several of these commands to clean out multiple folders. For example, I use
c:waRmZip.wsf /r c:\GV250\cam01 /ma:28 /md:c:\Backups\cam1\$YEAR /q
which first moves old files from cam01, then from cam02. There is no limit to the number of folders you can clean this way.
Finally, I use task scheduler (Start/Programs/Accessories/System Tools/Task Scheduler) to run the .bat file every day, so that the files that SugarSync syncs don't grow too large.
waRmZip can also compress files but this is functionality I don't need here. In fact, the only reason I every compress a file is to attach it to email, usually because I want to email a forbidden file like an executable.
Now I can see my security cam files on the web when I'm traveling, merely by logging into SugarSync's online interface and downloading the files onto my laptop. Of course, that wasn't the end of the saga -- my security cam uses a proprietary codec, gmpeg4, and I had to find a decoder for it and install it, and I can't do that with my favorite VLC so wound up using the odious windows media player, and using it on the phone remains impossible, but that is another story.
Now, if I could only get SugarSync to automatically clear out its deleted files...