How to list every alias in hard drive and target of alias too
this will list every alias on your hard drive:
set ls to do shell script "cd /; ls -F | grep -e \\@$"
set AppleScript's text item delimiters to return
set l to text items of ls as list
set AppleScript's text item delimiters to ""
set da to {}
repeat with i in l
set i to text items 1 through -2 of i
set i to i as text
set da to da & i
end repeat
da
you’re on your own for the following part. I think Jon’s Commands can do this.
I think the fastest available way to find files of a particular kind is to use mdfind. For example, to find all the aliases in your user’s directory: (leaving out the -onlyin PosixPath will find all mounted on your machine)
set myAliases to do shell script "mdfind -onlyin ~/ 'kMDItemKind == \"Alias\"'"
Once you’ve got a posix path to an alias, F, say:
set f to "A slash-delimited Address to the alias"
set hf to POSIX file f
tell application "Finder" to set O to original item of hf
Fiddling with this a bit produces:
set W to quoted form of (POSIX path of (choose folder with prompt "Find Aliases and Targets Where?"))
set tA to paragraphs of (do shell script "mdfind -onlyin " & W & " 'kMDItemKind == \"Alias\"'")
set targ to {}
repeat with Al in tA
set hf to POSIX file (contents of Al)
try
tell application "Finder" to set targ's end to {hf as alias, ((original item of hf) as alias)}
end try
end repeat
You do want to be fairly specific about this because there are a lot of unsuspected aliases belonging to Apps all over the place.