Hi Stefan
To get your script running flawlessly I converted an objet in quoted form
set brokenAliases to do shell script "/Users/admin/bin/AliasPath -b " & quoted form of aliasFilePaths
When I ran it I discovered that it is useless.
It returns a list of the path of the broken aliases, no less, no more.
In fact I’m not surprised because I get the same behavior when I try to use ASObjC to get the original of broken aliases.
So I decided to re-work my proposal. At this time, it is :
tell application "Finder"
set theWindows to every window
repeat with awindow in theWindows
# Close every info window once so we will not have to do it in the handler
if class of awindow is information window then close awindow
end repeat
end tell
set l to do shell script "mdfind \"kMDItemKind == 'Alias'\""
set y to ""
set n to ""
set pass to 0
repeat with e in paragraphs of l
set pass to pass + 1
log e
set p to POSIX file e
log p
try
tell application "Finder"
set a to p as alias
if original item of a exists then
set theOriginal to my getOriginal(e) # here e is a POSIX path
set y to y & e & tab & theOriginal & linefeed # Add path2alias & path2original in y
else
set theOriginal to my getOriginal(e) # here e is a POSIX path
set n to n & e & tab & theOriginal & linefeed # Add path2alias & path2original in n
log "***try"
end if
end tell
on error
set n to n & e & tab & "***error" & linefeed # Here, I get that with aliases appearing as greyed in the Finder window
log "***error"
end try
--if pass = 50 then exit repeat # active only during tests
end repeat
# Save the list of broken aliases
set f to open for access (path to desktop as text) & "FinderBrokenAliasesXXX.txt" with write permission
write n as text to f
close access f
# Save the list of correct aliases
set f to open for access (path to desktop as text) & "FinderCorrectAliasesXXX.txt" with write permission
write y as text to f
close access f
on getOriginal(brokenAliasPOSIXPath)
set aFile to POSIX file brokenAliasPOSIXPath
tell application "Finder"
(*
set theWindows to every window
repeat with awindow in theWindows
# Close every info window
if class of awindow is information window then close awindow
end repeat
*)
select aFile # open the window of the folder containing the alias
set aFile to aFile as text
repeat 10 times
if ((get selection) as text) = aFile then exit repeat # Wait for the window containing the file
delay 0.2
end repeat
end tell
tell application "System Events" to tell process "Finder"
set frontmost to true
keystroke "i" using {command down} # Ask for Info window
tell application "Finder"
repeat 10 times # Wait for the new info window
delay 0.2
if class of window 1 is information window then exit repeat
end repeat
end tell
tell window 1
--class of UI elements --> {scroll area, button, button, button, image, static text}
tell scroll area 1
--class of UI elements --> {image, static text, static text, static text, static text, scroll area, UI element, static text, static text, static text, static text, static text, static text, static text, static text, static text, static text, static text, static text, static text, static text, button, checkbox, UI element, static text, static text, UI element, static text, text field, checkbox, UI element, static text, UI element, static text, UI element, static text, static text, scroll area, button, button, menu button, checkbox}
set theTexts to value of static texts
repeat with i from 1 to count theTexts
if theTexts's item i is in {"Original :", "Original:"} then
set theOriginal to theTexts's item (i + 1)
exit repeat
end if
end repeat
end tell
-- subrole of buttons --> {"AXCloseButton", "AXZoomButton", "AXMinimizeButton"}
click button 1 # Close the Infos window
if i = (count theTexts) then set theOriginal to "?¿?¿?¿?¿?¿" # The window doesn't display an original, build a fake string
end tell # window 1
tell application "Finder" to close window 1
end tell
return theOriginal --> "/Important/Téléchargements/ téléchargés pour Leopard/maj_Apple"
end getOriginal
I’m not satisfied because :
(1) at this time it works only with French and English localization
(2) I’m not satisfied by the treatment of aliases generation the message “***error”
Here, these aliases are greyed in their Finder window and it’s that which generate the error. It’s boring because when I open their Info window by hand, I see that their original is defined.
Yvan KOENIG running Sierra 10.12.6 in French (VALLAURIS, France) mardi 25 juillet 2017 23:40:21