Thursday, May 28, 2020

#1 2020-01-02 03:59:31 pm

peavine
Member
From:: Prescott, Arizona
Registered: 2018-09-04
Posts: 480

System Events and Alias

I know I must be missing something really simple but can't figure it out.

The following works fine:

Applescript:

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

But the following throws an error:

Applescript:

set theFile to (choose file)
set theFolder to (choose folder)

tell application "System Events"
   move theFile to theFolder
end tell

The error is:

error "System Events got an error: Can’t make alias \"Macintosh HD:Users:bob:Downloads:New Text File.txt\" into type specifier." number -1700 from alias "Macintosh HD:Users:bob:Downloads:New Text File.txt" to specifier



In the second script I tried adding alias before theFile and theFolder without success. What am I doing wrong?


2018 Mac mini - macOS Catalina

Offline

 

#2 2020-01-02 04:50:07 pm

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 4370

Re: System Events and Alias

Hello peavine.

Which system are you running ?

Here, under 10.13.6, running

Applescript:

set theFile to (choose file)
log result
set theFolder to (choose folder)
log result

tell application "System Events"
   move theFile to theFolder
end tell

gave the history :

Applescript:


-- Don't click upon "Open this Scriplet in your Editor:", it's an history.

tell application "Script Editor"
   choose file
       --> alias "SSD 1000:Users:**********:Desktop:66382862_1_1 copie.pdf"
end tell
(*alias SSD 1000:Users:**********:Desktop:66382862_1_1 copie.pdf*)
tell application "Script Editor"
   choose folder
       --> alias "SSD 1000:Users:**********:Downloads:"
end tell
(*alias SSD 1000:Users:**********:Downloads:*)
tell application "System Events"
   move alias "SSD 1000:Users:**********:Downloads:66382862_1_1 copie.pdf" to alias "SSD 1000:Users:**********:Downloads:"
       --> file "SSD 1000:Users:**********:Downloads:66382862_1_1 copie.pdf"
end tell

Résultat :
file "SSD 1000:Users:**********:Downloads:66382862_1_1 copie.pdf" of application "System Events"

I'm really puzzled by what appears in this history.

The original file appears as :
(*alias SSD 1000:Users:**********:Desktop:66382862_1_1 copie.pdf*)
but the move instruction is reported as :
move alias "SSD 1000:Users:**********:Downloads:66382862_1_1 copie.pdf" to alias "SSD 1000:Users:**********:Downloads:"
        --> file "SSD 1000:Users:**********:Downloads:66382862_1_1 copie.pdf"

May be useful to get the permissions of the folder Download.

Here they are :

Résultat : 
me : lecture et écriture (read & write)
everyone  : Accès interdit (unauthorized access)


I got exactly what you got when I ran :

Applescript:

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 theFolder
end tell

It's logical because in this case, theFolder isn't an alias but, at best, a list of one alias.

--> error "Erreur dans System Events : Impossible de convertir {alias \"SSD 1000:Users:**********:Downloads:\"} en type location specifier ou text." number -1700 from {alias "SSD 1000:Users:**********:Downloads:"}

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) jeudi 2 janvier 2020  23:49:46

Last edited by Yvan Koenig (2020-01-02 05:12:52 pm)

Online

 

#3 2020-01-02 05:34:56 pm

Nigel Garvey
Moderator
From:: Warwickshire, England
Registered: 2002-11-20
Posts: 5203

Re: System Events and Alias

peavine wrote:

But the following throws an error:

Applescript:

set theFile to (choose file)
set theFolder to (choose folder)

tell application "System Events"
   move theFile to theFolder
end tell

The error is:

error "System Events got an error: Can’t make alias \"Macintosh HD:Users:bob:Downloads:New Text File.txt\" into type specifier." number -1700 from alias "Macintosh HD:Users:bob:Downloads:New Text File.txt" to specifier



In the second script I tried adding alias before theFile and theFolder without success. What am I doing wrong?


Hi peavine.

The script works on my Mojave system. It looks from your error message as if Catalina's System Events prefers its own specifiers as parameters for its commands.


NG

Online

 

#4 2020-01-02 06:25:44 pm

peavine
Member
From:: Prescott, Arizona
Registered: 2018-09-04
Posts: 480

Re: System Events and Alias

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:

Applescript:

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.

Last edited by peavine (2020-01-02 06:41:15 pm)


2018 Mac mini - macOS Catalina

Offline

 

#5 2020-01-03 02:10:06 am

ldicroce
Member
Registered: 2017-11-25
Posts: 197

Re: System Events and Alias

peavine wrote:

In the second script I tried adding alias before theFile and theFolder without success. What am I doing wrong?



I am also getting an error in Catalina 10.15.2

Offline

 

#6 2020-01-03 06:06:36 am

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 6369

Re: System Events and Alias

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».


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/
latenightsw.com

Offline

 

#7 2020-01-03 07:17:22 am

KniazidisR
Member
Registered: 2019-03-03
Posts: 1259

Re: System Events and Alias

ldicroce wrote:
peavine wrote:

In the second script I tried adding alias before theFile and theFolder without success. What am I doing wrong?



I am also getting an error in Catalina 10.15.2


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:

Applescript:

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:

Applescript:

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.

Last edited by KniazidisR (2020-01-03 08:07:51 am)


Model: MacBook Pro
OS X: Catalina 10.15.4
Web Browser: Safari 13.1
Ram: 4 GB

Offline

 

#8 2020-01-03 09:00:43 am

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 4370

Re: System Events and Alias

As I am pig headed I made a new test after editing the code using with multiple selections allowed.

Applescript:

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.

Applescript:



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 :

Applescript:

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

Last edited by Yvan Koenig (2020-01-03 09:04:40 am)

Online

 

#9 2020-01-03 09:52:41 am

peavine
Member
From:: Prescott, Arizona
Registered: 2018-09-04
Posts: 480

Re: System Events and Alias

Shane Stanley wrote:

FWIW, System Events is still accepting «class furl».


I ran Yvan's script from Post #8, which uses «class furl», and it works fine. That's very helpful.


2018 Mac mini - macOS Catalina

Offline

 

#10 2020-01-03 09:59:55 am

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 4370

Re: System Events and Alias

peavine wrote:
Shane Stanley wrote:

FWIW, System Events is still accepting «class furl».


I ran Yvan's script from Post #8, which uses «class furl», and it works fine. That's very helpful.



Were you originally using "with multiple selections allowed ?

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) vendredi 3 janvier 2020  16:59:49

Online

 

#11 2020-01-03 10:16:27 am

KniazidisR
Member
Registered: 2019-03-03
Posts: 1259

Re: System Events and Alias

peavine wrote:
Shane Stanley wrote:

FWIW, System Events is still accepting «class furl».


I ran Yvan's script from Post #8, which uses «class furl», and it works fine. That's very helpful.


So, you want to tell users that System Events cannot work with aliases, but only with furls?

Last edited by KniazidisR (2020-01-03 10:17:05 am)


Model: MacBook Pro
OS X: Catalina 10.15.4
Web Browser: Safari 13.1
Ram: 4 GB

Offline

 

#12 2020-01-03 10:18:30 am

ldicroce
Member
Registered: 2017-11-25
Posts: 197

Re: System Events and Alias

KniazidisR wrote:


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:

Applescript:

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.


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"

Last edited by ldicroce (2020-01-03 10:19:46 am)

Offline

 

#13 2020-01-03 10:19:55 am

peavine
Member
From:: Prescott, Arizona
Registered: 2018-09-04
Posts: 480

Re: System Events and Alias

Yvan Koenig wrote:

Were you originally using "with multiple selections allowed ?



In my original script, I did not use "with multiple selections allowed". 

Just to clarify, I ran the following script:

Applescript:

set theFile to (choose file)
set theFolder to (choose folder)

tell application "System Events"
   move theFile to theFolder
end tell

The result was:

error "System Events got an error: Can’t make alias \"Macintosh HD:Users:bob:Working:New Text File.txt\" into type specifier." number -1700 from alias "Macintosh HD:Users:bob:Working:New Text File.txt" to specifier



I ran the following and it worked without error:

Applescript:

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:

Applescript:

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.

Applescript:

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

Last edited by peavine (2020-01-03 12:53:21 pm)


2018 Mac mini - macOS Catalina

Offline

 

#14 2020-01-03 10:27:46 am

ldicroce
Member
Registered: 2017-11-25
Posts: 197

Re: System Events and Alias

KniazidisR wrote:
peavine wrote:
Shane Stanley wrote:

FWIW, System Events is still accepting «class furl».


I ran Yvan's script from Post #8, which uses «class furl», and it works fine. That's very helpful.


So, you want to tell users that System Events cannot work with aliases, but only with furls?



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.

Applescript:

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

Last edited by ldicroce (2020-01-03 10:29:14 am)

Offline

 

#15 2020-01-03 11:56:39 am

KniazidisR
Member
Registered: 2019-03-03
Posts: 1259

Re: System Events and Alias

ldicroce wrote:

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"


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 ...

Last edited by KniazidisR (2020-01-03 01:44:40 pm)


Model: MacBook Pro
OS X: Catalina 10.15.4
Web Browser: Safari 13.1
Ram: 4 GB

Offline

 

#16 2020-01-03 01:57:32 pm

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 4370

Re: System Events and Alias

KniazidisR wrote:
peavine wrote:
Shane Stanley wrote:

FWIW, System Events is still accepting «class furl».


I ran Yvan's script from Post #8, which uses «class furl», and it works fine. That's very helpful.


So, you want to tell users that System Events cannot work with aliases, but only with furls?



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

Last edited by Yvan Koenig (2020-01-03 02:00:12 pm)

Online

 

#17 2020-01-03 02:46:56 pm

KniazidisR
Member
Registered: 2019-03-03
Posts: 1259

Re: System Events and Alias

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):

Applescript:

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

Last edited by KniazidisR (2020-01-03 02:48:18 pm)


Model: MacBook Pro
OS X: Catalina 10.15.4
Web Browser: Safari 13.1
Ram: 4 GB

Offline

 

#18 2020-01-03 03:00:51 pm

peavine
Member
From:: Prescott, Arizona
Registered: 2018-09-04
Posts: 480

Re: System Events and Alias

Yvan Koenig wrote:

It would be useful to test how it behaves upon such objects with the commands : delete, duplicate, exists, save.


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.

Last edited by peavine (2020-01-03 03:09:04 pm)


2018 Mac mini - macOS Catalina

Offline

 

#19 2020-01-03 03:14:34 pm

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 4370

Re: System Events and Alias

peavine wrote:

Yvan. The delete, duplicate, and save commands all fail when used with alias specifiers under Catalina. The exists command does work, though.



Thank you, it's good to know.

It seems that it's time to file a report because it resemble to a bug in the interpreter used for commands working upon two file/folder specifiers.

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) vendredi 3 janvier 2020  22:12:07

Online

 

#20 2020-01-03 05:05:42 pm

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 6369

Re: System Events and Alias

KniazidisR wrote:

So, you want to tell users that System Events cannot work with aliases, but only with furls?



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.


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/
latenightsw.com

Offline

 

#21 2020-02-04 07:31:05 am

peavine
Member
From:: Prescott, Arizona
Registered: 2018-09-04
Posts: 480

Re: System Events and Alias

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».

Last edited by peavine (2020-02-04 07:32:58 am)


2018 Mac mini - macOS Catalina

Offline

 

#22 2020-02-04 09:19:53 am

CK
Member
From:: UK
Registered: 2018-11-04
Posts: 129

Re: System Events and Alias

peavine wrote:

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:

Applescript:

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.

Offline

 

#23 2020-03-24 03:59:51 pm

peavine
Member
From:: Prescott, Arizona
Registered: 2018-09-04
Posts: 480

Re: System Events and Alias

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:

Yvan Koenig wrote:

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



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.

Last edited by peavine (2020-03-26 07:41:40 am)


2018 Mac mini - macOS Catalina

Offline

 

#24 2020-03-24 04:10:34 pm

KniazidisR
Member
Registered: 2019-03-03
Posts: 1259

Re: System Events and Alias

peavine,

This works on new Catalina? :

Applescript:


set aFileHFSPath to (choose file) as text
set aFolderHFSPath to (choose folder) as text

tell application "System Events"
   set anAliasFile to alias aFileHFSPath
   set anAliasFolder to alias aFolderHFSPath
   move anAliasFile to anAliasFolder
end tell

Last edited by KniazidisR (2020-03-24 04:21:34 pm)


Model: MacBook Pro
OS X: Catalina 10.15.4
Web Browser: Safari 13.1
Ram: 4 GB

Offline

 

#25 2020-05-26 04:16:59 pm

peavine
Member
From:: Prescott, Arizona
Registered: 2018-09-04
Posts: 480

Re: System Events and Alias

I just installed macOS 10.15.5--which was released earlier today--and System Events still doesn't work with aliases under the circumstances detailed in post 1 and afterwards. If this issue hasn't been fixed by now it probably won't be, so I'll give up on this.

I hadn't before seen KniazidisR's post 24, but I tested his script and it threw the following error:

error "System Events got an error: NSArgumentsWrongScriptError" number 6

Last edited by peavine (2020-05-26 06:24:21 pm)


2018 Mac mini - macOS Catalina

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)