How to get original of an alias without asking the Finder?

I need to get the original item for aliases. The problem is I cannot ask the Finder, because I have to do this during a drop-operation in an AppleScriptStudio project, and if I do so, the Finder hangs for about 20 seconds.

Any help appreciatet, …

I don’t know if this will work but the theory is sound :). You can create an Objective-C class for your ASStudio project called AliasResolver. In that class you would define a class method that you would call in your script. But first, you will need the methods to resolve the alias. I found the following from

Put these method implementations in the AliasResolver.m file after the “@implementation AliasResolver” and before the “@end”. In the AliasResolver.h file you need to declare the method prototypes before the “@end” and after the closing brace “}”. The prototypes would look like:

  • (NSString*) pathResolved:(NSString*) inPath;
  • (BOOL) isAliasPath:(NSString *)inPath;
  • (NSString*) resolveAliasPath:(NSString*) inPath;

Now you can define a class method like so:

  • (NSString *)originalItemPathForAlias:(NSString *)aliasPath {
    AliasResolver *tmp = [[[AliasResolver alloc] init] autorelease];
    return [tmp resolveAliasPath:aliasPath];

Then in your script you use something like:

set originalPath to (call method "originalItemPathForAlias:" of class "AliasResolver" with parameter (POSIX path of aliasFilePath))

I haven’t done something like this in ASStudio in a while and I don’t have any of my projects that do this here at work, so I can’t verify and say this will work with certainty, but this is the basic idea. And I have tested the Obj-C code and it works fine.

I am missing something here, and I would really like to know what it is. Why can you not simply do this?

set a to choose file
-->alias "Pilate:Users:bhuricomepeerayos:Desktop:application2.doc"
set b to POSIX file (a's POSIX path)
-->file "Pilate:Users:bhuricomepeerayos:Desktop:application2.doc"

He’s looking to resolve aliases not aliases :). The kind you make when you Command-Option-drag a file in the Finder. And he wants to do it without a call to the Finder. I was surprised that System Events doesn’t have anything to handle this. But, then again, I might’ve missed something in its dictionary. And though Standard Additions can tell you if an item is an alias, it doesn’t appear to have the original item property. Hence my long and convoluted workaround.

I forgot to mention that I think the CoreServices frameworks need to be added to the project. This includes the CarbonCore framework which has the Alias.h file where the C functions used in the above Obj-C code is defined.


You could also use an idle handler to process your dropped items. See:


I can´t use the idle handler, because of the nasty bug that occurs when the idle handler fires during a delay. There is a thread about this here somewhere, and I know the alternatives for the delay statement, but they are not very useful for me.
thx anyway

Boah, that looks complicted. Thanks, going to try this tomorrow.

My limited testing shows that something like this may work:

choose file with prompt "Choose an alias:" without invisibles
set theAlias to result

	do shell script "/usr/bin/strings " & quoted form of ((POSIX path of theAlias) & "/rsrc") & " | /usr/bin/grep ':' | /usr/bin/colrm 1 1"
	set theOriginal to (first paragraph of result) as alias
on error errMsg number errNum
	display dialog "Error " & errNum & ":" & return & return & errMsg buttons {"Cancel"} default button 1 with icon caution
end try

Hi Spock,

You do know that you can add a command handler to your AS Studio app for ‘delay’.

delay 2

on delay n
		run script ("delay " & n)
	end try
end delay

When they fix the delay command, you can just remove this handler.


Bruce, you are my hero. I knew there must be a unix way to get it!
This should work until some programmer adds a “:” to a FileType or CreatorCode

If I do this, my application does not respond to button clicks until the delay has passed.

Hi Spock,

Then you can just use the idle handlers delay. Set a delay flag in the idle handler, so if the delay flag is true then delay a certain amount.


kel, could you explain that in more detail, please?

Basically what you do is control the delay from the idle handler. Something like this:

property the_delay : 2
property will_delay : false
on idle
	if will_delay then
		-- do nothing
		-- do whatever
	end if
	return the_delay
end idle

This is just to emphasize what you’re doing. From a separate script or threaded handler you adjust the property and the idle handler either delays or its routine.