Retrieve the original path from a broken alias

Having a list of aliases, I need to detect which one has a broken target path and I need also to get this path.


I've tested Applescript:


tell application "Finder"

try

set reference_doc to original item of (aliaspath_string as POSIX file as alias)

set originalpath_string to POSIX path of (reference_doc as alias)

on error

return empty

end try

end tell


but applescript is slow, it try always to mount remote servers and don't return the broken path. Any suggestion? Maybe a "do shell script" command line expression?


Thanks


Paul

Macbook Pro, Mac OS X (10.5.4)

Posted on Jun 10, 2014 5:40 AM

Reply
34 replies

Jun 16, 2014 6:50 AM in response to Hiroto

Well, I re-read the errors more carefully and noticed that such error as:


osascript[87424:507] Error loading ...:
    dlopen(...): no suitable image found.
    Did find: ...: no matching architecture in universal wrapper
osascript: OpenScripting.framework - scripting addition ... declares no loadable handlers.


is not only regarding architecture issue but also scripting addition's scheme.


cf.

AppleScript Release Notes

> 10.7 Changes

> Compatibility Notes



So the "arch -i386" technique won't work for it. You'd need to remove those old (and now useless) OSAXen from /Library/ScriptingAdditions.


Regards,

H

Jun 16, 2014 7:16 AM in response to Hiroto

I've used without problem the

/usr/bin/oasscript ~/desktop/test.applescript 2>/dev/null


Thank you very much for all, Hiroto. Just another rapid question: I have compiled a shell script ".m" (with a sudo xcodebuild install), and now I use directly the compiled version. If I move the compiled script to another machine, it will work? Or I should re-complie it on every Mac?

Jun 16, 2014 2:34 PM in response to pauclaude

Hello


Sorry I'm afraid I don't follow what you're doing. Are you writing objective-c programme (hence *.m file) that calls shell script via NSTask? If so, the portability of the compiled programme would obviously depend upon the availability of the resources used in the shell script on target machine(s). If not, I'm lost.


I don't use xcode myself as I'd rather do every thing in code without using nib. So if you need further help on xcode related problem, please start new thread on it so that more knowledgeable helpers can help you. 😉


Cheers,

H

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Retrieve the original path from a broken alias

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.