Repair alias

Is there any way to ‘repair’ a broken alias file in applescript ?

I tried this:

set x to (choose file) as string
tell application "Finder"
		get original item of alias file x
	on error
		set newPath to (choose file)
		set original item of alias file x to newPath
	end try
end tell

This results in an error.

What am I doing wrong or is it just not possible?

Thanks in advance



Hi John,

I think original item is read only (r/o) and choose file will not let you choose a disconnected alias. Anyway, here’s a workaround for this. The basic idea is to delete the old alias and make a new alias to a file chosen by the user.

tell application “Finder”
set s to (selection) as alias
get (original item of s)
set is_disconnected to false
on error – disconnected
set is_disconnected to true
end try
end tell
if is_disconnected then
set nf to (choose file with prompt “Reconnect alias to what file?”)
– add option for user to choose file or folder
tell application “Finder”
set dn to displayed name of s
set c to (container of s) as alias
delete s
make new alias to nf at c with properties {name:dn}
end tell
end if
return is_disconnected

Note that you must use the Finder’s selection as choose file will not allow disconnected alias.


Hi John,

I almost forgot this. If you look at my script, you’ll see a comment on adding an option for the user. You can tell if an alias file is an alias to a folder by looking at its file type. You can get the file type with the info for command. An alias file to a folder has file type “fdrp”. I’m not sure, but I think this is unique.