Automatic file renaming for Macs

At Exbiblio, in the absence of a good Mac version control system that's easy for normal users to understand, we had a convention of keeping all old versions of most of our files, naming them according to the date they were modified. An example might be:

April Budget-050402.xls

and if we wish to keep more than one version on any given date, then we use:

April Budget-050402-1.xls etc...

Sometimes we stick a userid at the end to indicate a modification of somebody else's file:

April Budget-050402-1-qsf.xls etc...

Renaming files all the time could be a little tedious, so I wrote a little script which does it for you, and using Wilfredo Sanchez' utility DropScript, I was able to convert it easily into a Mac app. You can put it in your Dock, for example, and drop a file onto it, and it will create a copy with today's date, and add a version number if a file with the new name already exists. Lastly, it opens the new file.

It's very unsophisticated, but it will attempt to do sensible things with existing filenames that obey its naming conventions:

For a file named:the copy on 21st Feb 2005 will be:
Myfile Myfile-050221
Myfile.txt Myfile-050221.txt
Myfile-041209.txt Myfile-050221.txt
Myfile-041209-1-qsf.txt Myfile-050221.txt
Myfile-041209.txt Myfile-050221-1.txt
if Myfile-050221.txt already exists, likewise for -2, -3 etc

It's not very tolerant of things that differ from our name-YYMMDD-vv-usr.ext format. Things which don't match (eg because they have spaces before the date instead of dashes) will probably just get the date appended to them. But it should be pretty safe.

A handy way to use this when you're working on a document is to click the little icon in the window header (which represents the file) and after a short pause, you can drag that onto DateOpen.

Dragging from the window title bar

A second window should open with the new, renamed, copy. If that little icon is greyed out, it probably means you need to save the file first.

I have no idea how useful this will be to anybody else, but I thought I'd post it anyway. If you want to change its functionality, for example if you'd prefer it not to open the file, right-click on it and select 'Show Package Contents'. In the Contents/Resources folder, you'll find a text file called 'script' which does the work, and which you can edit.

The Finder isn't always very good at detecting things happening behind its back. The script tells it to update the frontmost window, but if you dragged the file from elsewhere you may not immediately see the new file appear.

I offer this with no warranties, and all the usual disclaimers. Use at your own risk!

Here it is:

Oh, and it works with folders too.