Uli's Web Site
[ Zathras.de - Uli's Web Site ]
Other Sites: Stories
Abi 2000
Stargate: Resurgence
Lost? Site Map!
     home | blog | moose | programming | articles >> blog

 Blog Topics

15 Most Recent [RSS]

 Less work through Xcode and shell scripts
2011-12-16 @600
 iTunesCantComplain released
2011-10-28 @954
 Dennis Ritchie deceased
2011-10-13 @359
 Thank you, Steve.
2011-10-06 @374
 Cocoa Text System everywhere...
2011-03-27 @788
 Blog migration
2011-01-29 @520
 All you need to know about the Mac keyboard
2010-08-09 @488
 Review: Sherlock
2010-07-31 @978
 Playing with Objective C on Debian
2010-05-08 @456
 Fruit vs. Obst
2010-05-08 @439
 Mixed-language ambiguity
2010-04-15 @994
 Uli's 12:07 AM Law
2010-04-12 @881
 Uli's 1:24 AM Law
2010-04-12 @874
 Uli's 6:28 AM Law
2010-04-12 @869
 Uli's 3:57 PM Law
2010-04-12 @867


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
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)
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.

Reader Comments: (RSS Feed)
No comments yet
Or E-Mail Uli privately.
Created: 2005-08-12 @871 Last change: 2005-08-17 @991 | Home | Admin | Edit
© Copyright 2003-2017 by M. Uli Kusterer, all rights reserved.