(*
Copyright Atalantia©2015
*)
property dir1 : ""
property dir2 : ""
property dir3 : ""
property dir4 : ""
property ID1 : ""
property ID2 : ""
property mode : "Single"
property resMode : ""
property svc : false
on open var
setDir(item 1 of var)
end open
if dir1 = "" then setDir(path to desktop)
if resMode = "Big" and svc = true then
set {dif1, dif2, dif3, dif4} to {22, 0, 22, 0}
else if resMode = "Big" and svc = false then
set {dif1, dif2, dif3, dif4} to {44, 0, 66, 0}
else if resMode ≠ "Big" and svc = true then
set {dif1, dif2, dif3, dif4} to {46, -14, 36, -34}
else
set {dif1, dif2, dif3, dif4} to {76, -32, 76, -54}
end if
tell application "Finder"
activate
set {idList, wbo, noC} to {id of windows, bounds of window of desktop, {}}
repeat with x in idList
try
if x as number is not in {ID1, ID2} then close window id x
on error
set end of noC to x
end try
end repeat
set wiCount to (count Finder windows)
if wiCount ≠ 2 then
if wiCount = 1 then
set iFw1 to id of Finder window 1
if iFw1 = ID1 then
set ID2 to id of (make new Finder window to dir3)
set properties of window id ID2 to {current view:list view}
if mode = "Double" then
activate
my newTab()
set target of window id ID2 to dir4
set properties of window id ID2 to {current view:list view}
end if
else if iFw1 = ID2 then
set ID1 to id of (make new Finder window to dir1)
set properties of window id ID1 to {current view:list view}
if mode = "Double" then
activate
my newTab()
set target of window id ID1 to dir2
set properties of window id ID1 to {current view:list view}
end if
end if
else
try
set ID1 to id of (make new Finder window to dir1)
set properties of window id ID1 to {current view:list view}
if mode = "Double" then
activate
my newTab()
set target of window id ID1 to dir2
set properties of window id ID1 to {current view:list view}
end if
set ID2 to id of (make new Finder window to dir3)
set properties of window id ID2 to {current view:list view}
if mode = "Double" then
activate
my newTab()
set target of window id ID2 to dir4
set properties of window id ID2 to {current view:list view}
end if
on error
my setDir(path to desktop)
end try
end if
end if
set {m1, m3} to {(item 3 of wbo) * 0.125 as integer, (item 3 of wbo) * 0.875 as integer}
try
set {properties of window id ID1, properties of window id ID2} to {{bounds:m1 & ((item 2 of wbo) + dif1) & m3 & ((((item 4 of wbo) + 22) / 2) + dif2 as integer), toolbar visible:true, sidebar width:145}, {bounds:m1 & (((item 4 of wbo) + dif3) / 2 as integer) & m3 & (item 4 of wbo) + dif4, toolbar visible:true, sidebar width:145}}
end try
activate
if noC ≠ {} then
repeat with x in noC
open window id x
end repeat
end if
end tell
on newTab()
tell application "System Events" to keystroke "t" using command down
end newTab
on setDir(pathInfo)
set {dVar, svc, sv} to {" To reset the directories or mode, use the droplet function of this application.", false, system version of (system info)}
considering numeric strings
if sv > "10.9.5" then set svc to true
if sv ≥ "10.9.0" then set mode to button returned of (display alert "SingleTab or DoubleTab mode?" message "DoubleTab opens two tabs per window." & dVar buttons {"Cancel", "Single", "Double"} cancel button 1 default button 3)
end considering
set resMode to button returned of (display alert "Big or small Finder windows?" message "Big Finder Windows will cover the whole hight on the screen but not the entire width. Small Finder Windows will neither cover the whole hight nor the whole width on the screen." & dVar buttons {"Cancel", "Big", "Small"} cancel button 1 default button 3)
if mode = "Double" then
try
set {dir1, dir2, dir3, dir4} to {choose folder with prompt "Set directory 1." & dVar invisibles yes default location pathInfo, choose folder with prompt "Set directory 2." & dVar invisibles yes default location path to documents folder, choose folder with prompt "Set directory 3." & dVar invisibles yes, choose folder with prompt "Set directory 4." & dVar invisibles yes}
on error
set mode to ""
error number -128
end try
else
set {dir1, dir3} to {choose folder with prompt "Set directory 1." & dVar invisibles yes default location pathInfo, choose folder with prompt "Set directory 2." & dVar invisibles yes default location path to documents folder}
end if
run
end setDir