Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I use a lot of aliases in my file system. Many original documents are placed in global repositories and I access them by aliases grouped in "tag" folders. Therefore, when I need to delete such a document, I need to check multiple tag folders to remove the aliases, which pains.

Is there an application that can check for broken aliases in Finder (or preferably, a particular folder)? Thanks in advance.

share|improve this question
    
I'm not at my Mac to test this fully, but I believe that by using the command in a previous SU answer along with Hazel, you can create a rule to either alert you to broken links, color them, delete them, etc. – fideli Jan 5 '13 at 7:55
    
@fideli find -L . -type l -ls only works with symlinks. – user495470 Jan 5 '13 at 23:08
    
@LauriRanta Whoops, I thought Finder aliases are simply symlinks. Perhaps not. – fideli Jan 6 '13 at 0:31
up vote 1 down vote accepted

Try running something like this in AppleScript Editor:

set l to {}
tell application "Finder"
    try
        alias files of entire contents of (POSIX file "/Users/username/Folder/" as alias)
        -- zero aliases results in an error, one alias is not returned as a list
        result as list
    on error
        return
    end try
    repeat with f in result
        try
            original item of contents of f
        on error
            --move contents of f to trash
            set end of l to POSIX path of (f as text)
        end try
    end repeat
end tell
set text item delimiters to linefeed
l as text
share|improve this answer
    
Awesome script. Thank you so much. – 4ae1e1 Jan 6 '13 at 5:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .