NSIRCC.
Created my 2nd mini-application for my company today. This time, it was done to achieve a very simple goal… backing up files to a portable drive. So why did I need a mini application for that? Why can’t I just use a simple batch file to transfer the stupid .bak files over? Believe me, I appreciate simple solutions as well…
The problem was quite simple actually. The directory, which itself existed on a ANOTHER backup harddrive stored a few weeks worth of backup files (Complete Backups mind yer…), with a timestamp-suffix attached to each file. So, a simple batch command would have backed up ALL the damn files ( each file worth about 5GB), into the poor lil 80GB portable hard drive.
So this was where Java came in to save the day. The jar executable, would extract the Source and Destination directory through a Config.txt, and selectively COPY ONLY the day’s back up into the hard drive. I had a few ways to approach it. One was using the File.lastModified(), and then followed by comparing the current system date. But I took the short cut…
I took the System date, and manipulated it into a CCYYMMDD format that the timestamp was using, turned it into a String type, and simply selected the files that contained the current CCYYMMDD in their file names. I then took ANOTHER shortcut, by looping all the selected filenames in a DOS-Copy Command String, and threw it into a java runtime. (Screw cross platform operability, my company ONLY uses Microsoft stuff)
And that was all! A mini-backup utility within a day!
Now, for the record, I REALLY REALLY hate programming. I’m not good at it, and thats why I took a day to do this. =(