3

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.

4ae1e1
  • 1,586
  • 2
  • 14
  • 31
  • I'm not at my Mac to test this fully, but I believe that by using the command in a previous [SU answer](http://superuser.com/a/425851/19999) along with [Hazel](http://www.noodlesoft.com/hazel.php), you can create a rule to either alert you to broken links, color them, delete them, etc. – fideli Jan 05 '13 at 07:55
  • @fideli `find -L . -type l -ls` only works with symlinks. – Lri Jan 05 '13 at 23:08
  • @LauriRanta Whoops, I thought Finder aliases are simply symlinks. Perhaps not. – fideli Jan 06 '13 at 00:31

1 Answers1

1

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
Lri
  • 40,894
  • 7
  • 119
  • 157