Script Review??

Can someone tell me if there is a better what to do what I’m doing…
especially the part where i loop through by browser and open folders


tell application "Finder"
	set filePath to selection as text
end tell

set {myTID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, {":"}}
set myList to text items of filePath
set myList to myList's (items 1 thru -2)
-- It's considered good practice to return the TID's to their original state
set AppleScript's text item delimiters to myTID

tell application "ZigVersion" to activate
tell application "System Events" to tell process "ZigVersion"
	
	if exists button "Connect" of window "Connect to a Server" then
		set currentWindow to front window
		click button "Import a Working Copy..." of currentWindow
		-- make sure they are in outline view not colume view
		click radio button 1 of radio group 1 of group 1 of sheet 1 of currentWindow
		set i to 0
		set r to 0
		repeat with myItem in myList
			if i is equal to 0 then
				-- click the Macintosh HD button
				click button myItem of list 1 of scroll area 1 of splitter group 1 of group 1 of sheet 1 of currentWindow
			else
				repeat
					set r to r + 1 as number
					-- check to make sure we are on the right row
					get value of static text 1 of row r of outline 1 of scroll area 2 of splitter group 1 of group 1 of sheet 1 of currentWindow
					if result is equal to myItem as text then
						-- set row to current row index
						set theRow to row r of outline 1 of scroll area 2 of splitter group 1 of group 1 of sheet 1 of currentWindow
						tell theRow to set selected to true
						-- invoke a keyboard right arrow press to open folder
						--tell application "System Events" to keystroke return
						tell application "System Events" to key code 124
						delay 0.2
						exit repeat
					end if
				end repeat
				if i as number is equal to (count of myList) - 1 then
					-- import folder if we are at the desired location
					click button "Import Working Copy" of sheet 1 of currentWindow
				end if
			end if
			set i to i + 1
		end repeat
	end if
end tell

thanks

Hi,

One thing I see is that i is always 0 on the first loop. Then successive loops always check if i is 0. You should take that part out of the first repeat loop since it always runs:

if i is equal to 0 then
– click the Macintosh HD button
click button myItem of list 1 of scroll area 1 of splitter group 1 of group 1 of sheet 1 of currentWindow
else

I’m not sure what the second repeat loop is doing, but you should explain more when you post, so that someone whose helping you would have an easier time.

gl,