Finder New Window Script

Hi folks.

I have a script I call to put a new finder window somewhere on my multiple monitor setup. It’s broken somehow as I think El Capitan is forcing these recent windows without the Sidebar, which I definitely want in this new window. Upon invoking this script, a window appears in column view, but no sidebar and no ability to show the sidebar. It started recently and I’m not sure how I force this to happen. Command-N in the finder brings up a normal window with the sidebar, so I’m not sure why AS won’t do this as well, as it used to.

Any insight appreciated as to how to fix this.

tell application "Finder"
	activate
	set w to 620
	set h to 890
	-- replace x1 and y1 with Finder window 1 entries 1 and 2:
	set x1 to 3715
	set y1 to 40
	
	set w1 to make new Finder window
	tell w1 to set {bounds, current view} to {{x1, y1, (x1 + w), (y1 + h)}, column view}
end tell

Your script works fine for me as is, and the sidebar appears as well. Have you looked in your Finder Preferences? There is nothing there to directly instruct Finder to generate a sidebar, but there are plenty of Sidebar options.

Additionally, under General, you can select a specific folder in New Finder windows show:. In my case, I have selected a folder that appears in my sidebar. Interestingly, your script produces a Finder window with a sidebar, but that folder is not selected as it is when I press ⌘-N.

Playing around a little bit, I found that sidebar width is a programmable property for a Finder window. Try this:

tell w1 to set {bounds, current view, sidebar width} to {{x1, y1, (x1 + w), (y1 + h)}, column view, 180}

The 180 is from the properties of a new Finder window generated with ⌘-N.

Good luck,

And…of course…it’s now working. I haven’t changed a thing. It might have been solved by tweaking showing the toolbar in a previous result of that script. But I’m not sure.

Cheers

Hey daBee,

Don’t you just love that dreck…

Cmd-Opt-T and Cmd-Opt-S will alter your toolbar and sidebar set up, and there are some little quirks to the way AppleScript responds to this.

When I’m creating Finder windows I tend to enforce things like toolbar visible, sidebar width, and status bar visible.

Remember too that you can set a default window setup with Show View Options (⌘-J) in the Finder. The {Use as Defaults} button is at the bottom of the floating settings window.


property toolbarVisible : true
property statusbarVisible : true
property defaultSideBarWidth : 140

tell application "Finder"
	activate
	set w to 620
	set h to 890
	
	# Replace x1 and y1 with Finder window 1 entries 1 and 2:
	
	# Values of x1 & y1 changed to work on my system -ccs
	set x1 to 0
	set y1 to 23
	
	set newWindow to make new Finder window
	
	tell newWindow
		set {bounds, current view} to {{x1, y1, (x1 + w), (y1 + h)}, column view}
		if toolbar visible ≠ toolbarVisible then set toolbar visible to toolbarVisible
		if statusbar visible ≠ statusbarVisible then set statusbar visible to statusbarVisible
		if sidebar width ≠ defaultSideBarWidth then set sidebar width to defaultSideBarWidth
	end tell
	
end tell


Chris


{ MacBookPro6,1 · 2.66 GHz Intel Core i7 · 8GB RAM · OSX 10.11.2 }
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

OK. Yeah it’s a strange beast. I didn’t know it would be sticky like that. Sidebar is dependent upon Toolbar. My preferences were set years ago for this. Didn’t know that recent tickling would change that.

Cheers