Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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. –  ؘؘؘ Jan 5 '13 at 23:08
    
@LauriRanta Whoops, I thought Finder aliases are simply symlinks. Perhaps not. –  fideli Jan 6 '13 at 0:31

1 Answer 1

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. –  ksh Jan 6 '13 at 5:59

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.