In Mac Panther, How Can I Delete The Targets of a Folder of Aliases? Applescript?

Posted on 2005-04-27
Last Modified: 2013-12-26
Hi -

I have a folder of 7,000 aliases.
I need to delete the targets of these aliases.

EXTRA CREDIT (but not needed to win the points, )
Ideally, I'd like the alias deleted after its target is successfully found and deleted. That way I can see what aliases had no targets.

All of the targets are local, i.e., none are across a network.
Some aliases are broken.

Norton Disk Doctor made the folder of aliases to these files, which have damaged resources and therefore cannot be repaired and must be removed. As the alert reader can infer, I am in deep, deep trouble. Maybe later I can write upo the problem of never ending file corruption, but I don't have the strength to do that now. I have deadlines...

Simply selecting a group and pressing Cmd R is not helpful, because alot of windows open that I have to go through one at a time. Also, if a target is not found for one item in a group, I get no feedback and can;t be sure of the result.

FileBuddy seems like it should have this functionality, but I can't see that it does.

I know how to make an Applescript and run it if given the code, but I'd need to be walked through any other kind of script.
Question by:drburt1
    LVL 23

    Expert Comment

    Norton Disk doctor is not a very good disk diagnostic utility, especially for OS X 10.3.
    I would not trust its diagnosis, and I certainly would not delete any files it finds
    questionable without running DiskWarrior or TechTools first.

    Author Comment

    Hi -

    Yes, it's always good to remember what a mess Norton for Mac has turned into - Adobe has several postings about how Photoshop files can be damaged beyond recovery by NAV and Illustrator has problems.

    BUT consider:-

    1. Techtool Pro 4.04 (brand new) reports new damaged files if I run a 2nd test immediately after deleting all the damaged files it reports on its first test. (as does Norton DD)

    2. TT reports all is well when DD reports 100s of damaged files.
    Trying to open the files TT says are good proves DD was right - they can't be opened and an error message from any app trying to open it reports damaged resources.

    3. At least DD makes an alias of the damaged files, leaving you to pick them off one by one.
    TT just gives you a written list, so you can copy and paste each item one at a time into a search engine...

    4. Disk Warrior while excellent for what it does seems not to address damaged resource forks, but does issue (in unhelpful list form) a report on damaged 'custom icons". (I wonder what that's about?)

    Thanks for responding,

    LVL 6

    Accepted Solution

    This script should do the trick:

    set the theFolder to (choose folder with prompt "Pick the folder containing the aliases:")
    tell application "Finder"
          set aliasesToTest to every alias file of theFolder
          repeat with theAlias in aliasesToTest
                      delete original item of theAlias
                      delete theAlias
                end try
          end repeat
    end tell

    The line "delete original item of theAlias" will fail if the original does not exist and the alias file will therefore not be deleted by "delete theAlias"

    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    Join & Write a Comment

    Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
    Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
    This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now