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.

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

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! :confused:

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

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

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.

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

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…. :stuck_out_tongue: :expressionless:

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.

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


Hey, this is AppleScript we’re talking about :wink: