Friday, October 22, 2021

#1 2011-06-14 01:51:16 am

daBee
Member
From:: Toronto
Registered: 2010-02-09
Posts: 161

make new Finder window with properties...works?

Hi folks.

I'm trying to open a finder window with properties, but she doesn't want to take.

Applescript:


property myTarget : "/Users/rich/Documents/Scanned/"

tell application "Finder"
   set myW to make new Finder window with properties {current view:list view, toolbar visible:true, target:myTarget}
end tell

The target isn't being taken for some reason.  No errors, but it just won't go to the target I want.

Any ideas appreciated.

Cheers


Filed under: window, Finder, Properties

Offline

 

#2 2011-06-14 02:01:45 am

StefanK
Member
From:: St. Gallen, Switzerland
Registered: 2006-10-21
Posts: 11750
Website

Re: make new Finder window with properties...works?

Hi,

set the target in an extra line

Applescript:


set myTarget to (path to documents folder as text) & "Scanned:"

tell application "Finder"
   set myW to make new Finder window with properties {current view:list view, toolbar visible:true}
   set target of myW to myTarget
end tell

Note: AppleScript expects HFS paths (colon separated)


regards

Stefan

Offline

 

#3 2011-06-14 02:22:57 am

daBee
Member
From:: Toronto
Registered: 2010-02-09
Posts: 161

Re: make new Finder window with properties...works?

Ah very good.  Why won't the object take the setter method with parameters?  Neither target nor current view stuck as properties. 

Cheers

Offline

 

#4 2011-06-14 02:55:01 am

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

Re: make new Finder window with properties...works?

It often happens that some initial properties can't be set with the 'with properties' parameter — not just with the Finder, but with potentially any application. The reason could be a technicality to do with the kind of object being 'made' or an oversight or idiosyncasy on the part of the developer.

However, the Finder's implementation of 'make' has a 'to' parameter, which can be used with either 'alias files' or 'Finder windows'.

Applescript:


set myTarget to (path to documents folder as text) & "Scanned:"

tell application "Finder"
   set myW to make new Finder window to folder myTarget
   tell myW to set {current view, toolbar visible} to {list view, true}
end tell

Or, if you don't need to refer to the window again in the script:

Applescript:


set myTarget to (path to documents folder as text) & "Scanned:"

tell application "Finder"
   tell (make new Finder window to folder myTarget) to set {current view, toolbar visible} to {list view, true}
end tell

Last edited by Nigel Garvey (2011-06-14 02:56:56 am)


NG

Offline

 

#5 2011-06-14 02:59:03 am

daBee
Member
From:: Toronto
Registered: 2010-02-09
Posts: 161

Re: make new Finder window with properties...works?

Yes, those would be setter methods for an object oriented system.  The instance of the object, given properties, should stick.  I'd say this is a fault with something.  Modifying properties after the object is made shows their onCreate methods lack proper attribute assignment. 

LOL I never got AS syntax. 

Cheers

Offline

 

#6 2013-11-06 12:29:37 pm

noiroi
Member
Registered: 2006-03-02
Posts: 24

Re: make new Finder window with properties...works?

Sorry to resurrect this old post, but I wonder: Did anybody find a solution by now?

Is it possible to set a Finder window's properties, such as view, target, icon size, bounds, etc. before making the widow?
Otherwise you can actually see the changes occur, which is somewhat inelegant.....

Thanks!

Offline

 

#7 2013-11-06 12:58:22 pm

McUsrII
Member
Registered: 2012-11-21
Posts: 3046
Website

Re: make new Finder window with properties...works?

Sorry, nope you can't set properties of a finder window, or any window before you create it.

Offline

 

#8 2013-11-06 02:35:02 pm

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

Re: make new Finder window with properties...works?

It is actually possible to set the view and view options before opening a window:

Applescript:


set myTarget to (path to documents folder as text) & "Scanned:"

tell application "Finder"
   tell container window of folder myTarget
       set current view to list view
       set icon size of its list view options to large icon
       open
       set its bounds to {50, 50, 800, 800}
       set its toolbar visible to true
   end tell
end tell


NG

Offline

 

#9 2013-11-06 02:52:47 pm

McUsrII
Member
Registered: 2012-11-21
Posts: 3046
Website

Re: make new Finder window with properties...works?

I'm sorry. I have never noticed the container window before. At least I can't recall having used it.

Thanks for showing that the toolbar visible still works. I was sure it was gone now,with the additions of the tabs. smile

Offline

 

#10 2019-04-16 11:05:43 pm

Mr. Science
Member
From:: Satellite Beach, Florida
Registered: 2015-08-13
Posts: 73
Website

Re: make new Finder window with properties...works?

This worked for me. It's somewhat of a preset, and it worked as a one-liner too. The new window is quickly modified even though it's properties (other than target) are not actually set prior to the window appearing. But the values are!

Applescript:


   set myTarget to path to desktop folder as text
   set myBounds to {5, 10, 50, 100}
   set myZoomed to false --some item of {true, false} --
   set myCollapsed to false --some item of {true, false} --
   set myView to list view --some item of {list view, column view, icon view, flow view} --
   set mySidebar to 150 --(some item of {0, 100, 200, 300}) --300 --
   
   set {newWNDW, properties of newWNDW} to {make new Finder window, {target:myTarget, bounds:myBounds, zoomed:myZoomed, collapsed:myCollapsed, current view:myView, sidebar width:mySidebar}}
   
   return properties of newWNDW

Model: Mac Pro, Yosemite
AppleScript: 2.7
Browser: Safari 601.2.7
Operating System: macOS 10.14


"Fail and fail until you fail to fail!"   ~   http://www.theMrScienceShow.com

Offline

 

#11 2019-04-17 02:06:53 am

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

Re: make new Finder window with properties...works?

For me too, if I include the :


Applescript:

tell application "Finder"

end tell

Last edited by ldicroce (2019-04-17 02:07:23 am)

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)