Thanks Yvan and Nigel. I worked with this some more, testing it with varous folders and running it with Script Editor and Fastscripts, but I always receive the same result. I tried the following and System Events does recognize the alias:
tell application "System Events"
alias "Macintosh HD:Users:bob:Working:New Text File.txt"
end tell --> alias "Macintosh HD:Users:bob:Working:New Text File.txt"
I also tried the duplicate command but got the same error message. So, it does appear that this is an issue only when an alias is used a specifier for a command and only on Catalina.
FWIW, I see the same. So aliases are failing in System Events, Image Events, and Adobe apps, at the least. That sounds awfully like something outside the apps failing.
FWIW, System Events is still accepting «class furl».
That is not because of Catalina 10.15.2. Simply you can’t create System Events aliases from AppleScript aliases. But you can create them from HFS paths.
System Events has its own class of aliases, which doesn’t usual AppleScript aliases. So, to use its own aliases with System Events you should create them into the tell application “System Events” block. And this is not bug of Catalina. The Apple OS is designed this way:
set theFile to (choose file) as text
set theFolder to (choose folder) as text
tell application "System Events"
move alias theFile to alias theFolder
{alias theFile, alias theFolder}
end tell
NOTE: I added the result list, so you can see what is the System Event’s aliases. As you can see, theSystem Event’s aliases shows all its properties in the Script Debugger, but AppleScript aliases doesn’t show.
Here is System Event’s alias more clear code to understand what I say above:
set theFile to (choose file) as text
set appleScriptAlias to alias theFile
tell application "System Events" to set systemEventsAlias to alias theFile
see in the Script Debugger appleScriptAlias, than see systemEventsAlias. The first doesn’t show its properties
NOTE: System Events, can process directly AppleScript aliases as well as its own aliases.
As I am pig headed I made a new test after editing the code using with multiple selections allowed.
set theFile to (choose file)
log result
set theFolder to (choose folder with multiple selections allowed)
log result
tell application "System Events"
move theFile to (item 1 of theFolder) -- EDITED
end tell
This time, as it no longer pass a list of aliases but a single alias, it behaves flawlessly.
Don't click [Open this Scriplet in your Editor:],here is a Log History
tell application "Script Editor"
choose file
--> alias "SSD 1000:Users:**********:Desktop:aapart_taxe_habitation copie.pdf"
end tell
(*alias SSD 1000:Users:**********:Desktop:aapart_taxe_habitation copie.pdf*)
tell application "Script Editor"
choose folder with multiple selections allowed
--> {alias "SSD 1000:Users:**********:Desktop:ƒ Disques anciens:"}
end tell
(*alias SSD 1000:Users:**********:Desktop:ƒ Disques anciens:*)
tell application "System Events"
move alias "SSD 1000:Users:**********:Desktop:aapart_taxe_habitation copie.pdf" to alias "SSD 1000:Users:**********:Desktop:ƒ Disques anciens:"
--> file "SSD 1000:Users:**********:Desktop:ƒ Disques anciens:aapart_taxe_habitation copie.pdf"
end tell
Résultat :
file "SSD 1000:Users:**********:Desktop:ƒ Disques anciens:aapart_taxe_habitation copie.pdf" of application "System Events"
Using «class furl», it behaves well with :
set theFile to (choose file)
log result
set theFolder to (choose folder with multiple selections allowed)
log result
tell application "System Events"
move theFile as «class furl» to (item 1 of theFolder as «class furl»)
end tell
Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) vendredi 3 janvier 2020 16:00:10
I am not sure I understood you completely, but the above script is still not working for me.
It triggers the following error:
“System Events got an error: NSArgumentsWrongScriptError”
In my original script, I did not use “with multiple selections allowed”.
Just to clarify, I ran the following script:
set theFile to (choose file)
set theFolder to (choose folder)
tell application "System Events"
move theFile to theFolder
end tell
The result was:
I ran the following and it worked without error:
set theFile to (choose file)
set theFolder to (choose folder)
tell application "System Events"
move theFile as «class furl» to theFolder as «class furl»
end tell
The following also worked without error:
set theFile to (choose file) as text
set theFolder to (choose folder) as text
tell application "System Events"
move file theFile to folder theFolder
end tell
Finally, the following–which is a slight variant of the preceding script–also works.
set theFile to (choose file)
set theFolder to (choose folder)
tell application "System Events"
move file (theFile as text) to folder (theFolder as text)
end tell
If that is true then why using the script below I can collect info on those alises?
Alias are indeed recognised within the tell application “System Events” handler. Otherwise the get properties of theFile would have triggered an error.
It seems to me that move command is failing.
set theFile to (choose file)
set theFolder to (choose folder)
tell application "System Events"
get properties of theFile --> it does work !
get properties of theFolder --> it does work !
move theFile to theFolder --> gives an error !
end tell
As Nigel Garvey sad, on some systems (as on Mojave) System Events can deal with AppleScript aliases directly. On others System Events want only its own aliases, and generally, its own file references. It seems, on the Catalina too. That is bad. Because you should use coercion.
I just wanted to show how to create System Events alias (on Mojave), and to make it clear why the error occurs. Although, there is little practical benefit from this, as Peavine noted.
Conclusion: So I’m right that I’m not switching to Catalina yet. Actually, I worked with Yosemite, El Capitan, Mojave. I did not find so many bugs in all taken together, as in High Sierra. I uninstalled it as quickly as possible. Catalina seems to be an even more raw product. All Mac OS X applications should work seamlessly with AppleScript aliases. This is the purpose of AppleScript aliases, and for this they were invented …
No, under Catalina, System Events is able to execute:
(1) move file (anAliasItem as text) to folder (anAliasFolder as text)
(2) move (anAliasItem as «class furl») to (anAliasFolder as «class furl»)
but it fails to execute:
(3) move anAliasItem to anAliasFolder
At this time we know also that it’s able to grab properties of anAliasItem.
It would be useful to test how it behaves upon such objects with the commands : delete, duplicate, exists, save.
Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) vendredi 3 janvier 2020 20:57:26
I was more interested to learn this: I know that on some older systems the following code gives the desired result (on Mojave, which is new system, too). And on Catalina, System Events cannot even work with its own aliases, (as idicore reports):
set anAliasFile to (choose file)
set anAliasFolder to (choose folder)
tell application "System Events"
set anAliasFile to alias (anAliasFile as text)
set anAliasFolder to alias (anAliasFolder as text)
move anAliasFile to anAliasFolder
end tell
Yvan. The delete, duplicate, and save commands all fail when used with alias specifiers under Catalina, and the error messages are as quoted in my above post. The exists command does work, though.
No. My point was that dealing with aliases seems to be a problem that’s cropping up in several places in 10.15, and that so far, all of them will accept a «class furl» instead. So if someone hits the problem in another app, it may be worth their trying «class furl» for a workaround.
You are right that System Events defines its own alias class, but it has also worked with normal aliases in all versions up to 10.15, so something has changed. If the problem was only in System Events, I’d be looking more closely at its own alias class, but the fact that it’s cropping up elsewhere makes me suspect the problem is somewhere else.
I installed the just-released macOS Catalina 10.15.3 and reran the tests in my first post in this thread. System Events still seems not to work reliably with aliases. The best workaround, as Yvan and Shane suggest, seems to be to use «class furl».
You can also use paths with System Events as plain text strings in many situations:
set f to (choose file) as text
set d to (choose folder) as text
tell application "System Events"
move f to d
end tell
This works on Catalina with both HFS and posix paths for use with commands, but, of course, a string is still just a string so can’t yield any properties relating to file objects without using an object specifier or coercion.
I installed the just-released macOS Catalina 10.15.4 and reran the tests in my first post in this thread. System Events still seems not to work reliably with aliases. The best workarounds seem to be to use «class furl» or to coerce the alias to text. Yvan earlier summarized this as follows:
I did some additional testing and found that:
The move command doesn’t work with AppleScript or System Events aliases.
The duplicate command doesn’t work with AppleScript or System Events aliases.
The delete command works with System Events aliases but not with AppleScript aliases.