Mac OSX 10.6
I've got some aliases that are pointing to the wrong volume. I'd like to search my whole hierarchy for such aliases. They're aliases, not symlinks, so I can't just do find / -type l -ls | grep badVolumeName
.
It seems that aliases have a com.apple.ResourceFork, but querying this with xattr
gives me binary data. Is there a way to dump the target of the alias as text so I can grep for the bad volume name? Or what's another way to do this?
To find alias files you can make use of this answer on StackOverflow. First, create a script
is_alias.sh
:and then run
Getting the path of an alias seems quite difficult.
Someone has posted a solution using MacPerl, but as I do not have MacPerl I haven't tested this and don't know whether it works.
There is a similar question on AskDifferent, with several different suggestions, but none of them seem to actually solve the problem. The Applescript answer is okay, but the key operation, getting the "original item" of an alias file, doesn't seem to work for broken aliases.
You can also take a look at this question which might have some Cocoa solutions.