making a new Finder window . . . with properties

In an earlier post, Hows does one come up with a useful script??? by knightjp, I suggest Julz write a script that would duplicate a window for easy manual transfer of files. Of course the reason I suggested it was because I was working on one myself. And I’ve got it working just the way I want it (code at the bottom). But I had some trouble with the ‘make new Finder window’ command. When I used either this

		make new Finder window at front with properties {bounds:newWindowBounds, current view:origWindowCurrentView} to origWindowTarget

or this

		make new Finder window at front to origWindowTarget with properties {bounds:newWindowBounds, current view:origWindowCurrentView} 

the script would make the window, but would not implement the properties I wanted. I finally just used the three lines below and let it got at that.

		make new Finder window at front to origWindowTarget
		set bounds of window 1 to newWindowBounds
		set current view of window 1 to origWindowCurrentView

The question of course is why aren’t the ‘with properties’ part of the command working?

duplicateCurrentFinderWindow()

to duplicateCurrentFinderWindow()
	-- v1.00
	-- Independent
	
	tell application "Finder"
		set desktopWinBounds to bounds of window of desktop
		set yMax to item 4 of desktopWinBounds
		
		set origWindowName to name of window 1
		set origWindowBounds to bounds of window origWindowName
		set yOrigPos to item 2 of origWindowBounds
		set xNewPos to (item 1 of origWindowBounds) + 50
		set yNewPos to 44
		if yOrigPos ≤ (yMax div 3) then ¬
			set yNewPos to yMax - (item 4 of origWindowBounds) + (item 2 of origWindowBounds)
		set xNewEnd to (item 3 of origWindowBounds) - (item 1 of origWindowBounds) + xNewPos
		set yNewEnd to (item 4 of origWindowBounds) - (item 2 of origWindowBounds) + yNewPos
		set newWindowBounds to {xNewPos, yNewPos, xNewEnd, yNewEnd}
		set origWindowTarget to target of window origWindowName
		set origWindowCurrentView to current view of window origWindowName
		
		make new Finder window at front to origWindowTarget
		set bounds of window 1 to newWindowBounds
		set current view of window 1 to origWindowCurrentView
	end tell -- application "Finder"
end duplicateCurrentFinderWindow

It not just New Window, I found it on New Alias and New Folder too. Some with properties work some do not. Like color index doesn’t. Again you can set later. Just got to work around these faults. We have Leopard soon, hope for a real change in Applescripting the Finder as it has been completely rewritten.

The Finder’s ‘make’ command returns a reference to the created object, so if you’re desperate to use one line instead of three:

tell (make new Finder window to origWindowTarget) to set {bounds, current view} to {newWindowBounds, origWindowCurrentView}

bevos - nice to know I’m not crazy . . . but isn’t this like . . . OS 10.4??? :lol: Well, I guess good things are worth waiting for.

Nigel - I’m not really desperate to have it on one line. Actually kinda like it on three. Just couldn’t figure out why it wouldn’t work like the 20-odd year old dictionary said it should.

Thanks to both. :slight_smile: