Contextual File Archive
Posted in Ramblings, Theory, Uncategorized on November 29th, 2006 by Peter Wooley – Be the first to commentFor the past year or so, I’ve been archiving files in one particular manner: theFile_MM-DD-YYYY.html. Essentially, I do this to every file I need to make changes to, but may destroy with those changes.For nearly as long as I’ve done this, I’ve been trying to figure out how I could automate this process. I took a C++ course and tried to mash things up there — but it certainly did not work. I’ve thought of web apps (believe me), I’ve searched far and wide for a usable software package (particularly freeware) that would only add a ‘Duplicate’ option to the Context Menu, and found nothing. All I was able to find was bloated shareware or poorly written (and designed) freeware that did much more than I wanted it to do.Finally, today I realized what I needed: a batch file!Unfortunately, as of earlier today, I had no idea how to write a batch file. I knew you could use DOS code, but I’m not quite young enough to remember all the COPY, SET, REM and other commands.I was able to spend some time investigating via a search engine and was able to find out how to do what I needed!What I’ve ended up with is, in my very humble opinion, sweet. Utilizing seamonkey420’s Date Grabber I was able to create a batch file titled ‘archive.bat’ that allows you to archive a chosen file.In order to use this on any file, you’ll need to add a Context Menu item that allows you to run the batch file. In order to do this, download the file and store it anywhere you’d like, open up My Computer (or any windows explorer window), go to the Tools menu and choose the Folder Options menu item. Once there, choose the File Types tab and scroll through the list to a file you would like to be able to archive with two clicks (txt is a great one to test with) and select it. Now, look for the Advanced button near the bottom of the window and select it. Next, choose the New button: fill in the Action field with a description of this feature (I used ‘Archive’) and fill in the Application used to perform action field with the location of the archive.bat (via the Browse button). Click OK until you’re out of the Folder Options window and find a file with the extension .txt (if you cannot find one, you can create one, or use the above process on another filetype that you do have, perhaps .mp3 or .doc).When you’ve found the appropriate file, right-click the file, and if all has gone well, you should see ‘Archive’ (or the title you chose) in the Context Menu, and when you click it, the file is copied and the date is appended to the end of the filename, thus creating an archive!I’ve tested this with many file types (html, css, js, mov, fla, swf, txt, doc, psd, pdf, et al) and had no problems with them. However, this file and tutorial are given to you with absolutely no warranty If this causes any problems on your machine, you have my apologies, but please realize that if you use this, it’s at your own risk — just from one developer to another!If you would like to know more about what the file is doing, feel free to download the commented file and read throgh what exactly is going on. It took me a while to understand the code and syntax, but it was actually quite fun learning!If you do happen to spot any glaring bugs, or know of a better way to do this: let me know! Enjoy!I’d like to thank all the sites that I used in my quest for Batch commands and syntax:The Elder GeekB Brown TechRecipesTech TargetRob van der Woudeand Neil Turner, who reminded me I wanted to do this with his PNG Compress instructions