Tuesday, January 23, 2018

#1 2017-12-29 12:31:23 pm

danaeugene
Member
Registered: 2017-04-02
Posts: 5

Unable to set "new window target" of finder preferences

I've been unable to successfully change the "new window target" preference of finder preferences using AppleScript.  I've tried many different scripts which will compile but always end up with an error.  I have set the "everyones privileges" preference of the "new window target" preferences to "read write" thinking that might be the problem but it did not solve the problem.  I can "get" the "new window target." The result of the "get" is folder "Documents" of folder "danaeugene" of folder "Users" of startup disk.  The error I receive with the current "set" script is Finder got an error: Can’t set new window target of Finder preferences to folder "Desktop" of folder "danaeugene" of folder "Users" of disk "Macintosh HD".  I am not trying to accomplish this as part of a larger script but was going through the dictionary trying to understand better how to use it.  Since the dictionary showed that the "new window target" property can be accessed with get/set I thought I would be able to "set" the "new window target" to a different folder.  Mac OS is version 10.13.2 (17C88). Any help would be greatly appreciated.


Applescript:

tell application "Finder"
   set new window target of Finder preferences to folder "Desktop" of folder "danaeugene" of folder "Users" of disk "Macintosh HD"
end tell

Model: iMac (21.5-inch, Mid 2010)
AppleScript: 2.4
Browser: Safari 604.4.7
Operating System: Other

Offline

 

#2 2017-12-29 01:57:16 pm

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

Re: Unable to set "new window target" of finder preferences

Hi. Welcome to MacScripter.

If you look under 'application' in the Finder dictionary's 'Finder Basics' suite, you'll see that the Finder preferences are themselves read-only, so you won't be able to set any of their properties. It's often necessary to look elsewhere than the immediate entry in a dictionary to find some vital piece of information!  hmm


NG

Offline

 

#3 2017-12-29 03:08:33 pm

danaeugene
Member
Registered: 2017-04-02
Posts: 5

Re: Unable to set "new window target" of finder preferences

Thanks Nigel.  I appreciate your prompt reply.  I'll go back to studying the dictionary.  Dana

Offline

 

#4 2017-12-29 04:52:19 pm

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

Re: Unable to set "new window target" of finder preferences

I fear Nigel is enjoying the season too well smile You can certainly set other Finder preferences properties. For example:

Applescript:

tell application "Finder"
   set all name extensions showing of Finder preferences to true
end tell

My guess is that what you're seeing is simply a bug: either it should work but doesn't, or it should be marked read-only.


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

Offline

 

#5 2017-12-29 05:01:37 pm

danaeugene
Member
Registered: 2017-04-02
Posts: 5

Re: Unable to set "new window target" of finder preferences

Thank you Shane.  I appreciate the help. As I've heard Gary Rozensweig of MacMost say "AppleScript can be a very frustrating language."  It can also be very enjoyable though when I get something to work that otherwise would take a lot of mousing and clicking.  Thanks again.  Dana

Offline

 

#6 2017-12-29 06:10:50 pm

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

Re: Unable to set "new window target" of finder preferences

Shane Stanley wrote:

I fear Nigel is enjoying the season too well smile You can certainly set other Finder preferences properties.


Well the Finder dictionary in 10.13.2 definitely says the Finder preferences are "r/o" — which of course I'm assuming from past experience means "read only" and not something like "right on!", "rushed over", or "really orkward" — so if it is possible to set some of them, that's something else Dana's learned about scripting dictionaries….  tongue neutral


NG

Offline

 

#7 2017-12-29 06:56:57 pm

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

Re: Unable to set "new window target" of finder preferences

Nigel Garvey wrote:

Well the Finder dictionary in 10.13.2 definitely says the Finder preferences are "r/o"



Yes, but that just means you can't set the Finder preferences property to a different preferences object. That doesn't preclude changing the properties of that object. It's similar to properties like Finder window's list view options property.


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

Offline

 

#8 2017-12-30 04:27:17 am

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

Re: Unable to set "new window target" of finder preferences

Ah yes. Of course. Like a mutable object in an immutable array or dictionary in ASObjC. It could be clearer though.


NG

Offline

 

#9 2017-12-30 06:13:04 am

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

Re: Unable to set "new window target" of finder preferences

Nigel Garvey wrote:

Like a mutable object in an immutable array or dictionary in ASObjC.



Exactly.

It could be clearer though.



Hey, this is AppleScript we're talking about wink


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

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)