15 Most Recent [RSS]
More...
|
Spotlighting Removed Media
Way back in the System 7 days, there was a fun little INIT (system extension) called DiskCat, which created a folder for every floppy you inserted into your Mac's disk drive on your hard disk, containing aliases to all files on it. The nice part about this was that, if you were looking for a file, you simply fired up Find File and it would immediately tell you what disk it was on.
Even better: Since these were Aliases and Aliases are smarter than Symbolic links, you could double-click such a file and it would ask you to insert the correct floppy, telling you the name. So, if your floppies' names and their labels matched (admittedly a rare occurrence), it was fairly easy to keep track of all that junk.
When I recently couldn't find a file, for a moment I wished I could use Spotlight to search for it. And then I realized that I could. I first thought I'd try using Automator for the first time, but sadly it seems to be completely unaware of Aliases... So, I bit the bullet and used AppleScript, after finding that there seem to be no simple C APIs nor command-line tools that can create an Alias File easily.
After a little fighting, I ended up with a little AppleScript on which you can drop a CD or DVD (or even a folder, though I'm not sure why you'd want that) to have it recreate the folder hierarchy in it and fill it with Aliases of all the files. Nifty, eh?
Here's the script, for anyone who would like to use it, too:
property destDrive : "Jumper:" as alias (* change this to point to wherever you want your index - note that the index will automatically be inside a subfolder named "DiskIndex", so "Macintosh HD:Users:jeff:" is fine. *)
on open (fileList) tell application "Finder" copy item 1 of fileList to selectedFolder try set indexFolder to make new folder at destDrive with properties {name:"DiskIndex"} on error set indexFolder to folder "DiskIndex" of destDrive end try my makeShadowCopyOfFolder(selectedFolder, indexFolder) end tell end open
on makeShadowCopyOfFolder(selectedFolder, destFolder) tell application "Finder" set selFoldName to (displayed name of selectedFolder) try set indexFolder to (make new folder at destFolder with properties {name:selFoldName}) on error set indexFolder to folder selFoldName of destFolder end try set myFiles to the files in selectedFolder repeat with theFile in myFiles make alias at indexFolder to theFile end repeat set myFolders to the folders in selectedFolder repeat with theFolder in myFolders set theFoldName to displayed name of theFolder make new folder at indexFolder with properties {name:theFoldName} my makeShadowCopyOfFolder(theFolder, indexFolder) end repeat end tell end makeShadowCopyOfFolder
If any of you have experience with AppleScript Studio, it'd be cool if you wanted to wrap this in a nice app that puts up a progress bar while it works (of course it should reflect how many files to go). Also, anyone got Folder Actions working on Tiger? For me the menu items seem to be dead?? I'd love if someone was able to explain to me how I'd get it to index all removable media that show up in /Volumes.
Update: Of course I completely forgot that NDAlias supports creation of alias files these days. I mean, I've only been using Nathan's class for a year or so, so why would I ... *sigh* the basic Cocoa version works now.
Update 2: The Cocoa app is now available on this web site. Check out ShadowCopy 0.1 on the Source Code page.
| |