iSale Auction Backup Script

Hi there

iSale is an Ebay Assistant App from equinux. I have over 200 Auctions and I wrote a Script to make the Backup of all my Auctions a little bit easier.

Problem: Every auction is just a backup of my first auctions. That means: there are 200 files named after each auction…ok…but if I import them back to iSale it’s alway my first actions.

Seems like something with the repeat statement is not ok…

anyway, here’s the script…ah and I have Version 4.2.2, running on Leopard 10.5.4.

tell application "iSale 4"
	activate
	set countofactions to (count of auctions)
end tell

repeat with each from 1 to countofactions
	
	-- create title of exported action
	tell application "iSale 4"
		tell auction each
			
			if hitcount = 0 then
				set theTitle to (title)
				
			else if bidcount ≠ 0 then
				set theTitle to (title) & " @Sold"
				
			else
				set theTitle to (title) & " @Not"
				
			end if
		end tell
	end tell
	
	-- do the saving
	tell application "System Events"
		tell process "iSale 4"
			
			click menu item "Auction." of menu 1 of menu item "Export" of menu 1 of menu bar item "File" of menu bar 1
			delay 1
			
			tell sheet 1 of window "iSale"
				keystroke "g" using {command down, shift down}
				delay 0.5
				tell sheet 1
					set value of text field 1 to "~/Documents/Save/iSale/" & theTitle
					click button "Go"
				end tell
				delay 0.5
				click button "Save"
			end tell
		end tell
	end tell
	
end repeat

Thanks for your help!

Simon

Since you’re gui scripting the save, you need to make sure that the auction you want to save is the front most window. I don’t have iSale so I can’t be sure, but perhaps you can put an activate command after the ‘tell auction each’ line.

unfortunately that didn’t solved the problem…

But I found out that the script creates backups of the SELECTED auction, not the first…so it creates 200+ backups of the auction I selected before the script was invoked

Hey

Found the solution by myself! Here’s the script:

tell application "iSale 4"
	activate
	set countofactions to (count of auctions)
	display dialog "Make sure you selected your very first auction in your 'All Auctions' Group! Since we are GUI-Scripting here you should not touch your Mac for the next approx. " & (countofactions * 10.65) / 60 & " minutes" buttons {"Cancel", "OK"} default button 2
end tell

if the button returned of the result is "OK" then
	
	--set T1 to minutes of (current date)
	--set T1s to seconds of (current date)
	
	repeat with each from 1 to countofactions
		
		-- create title of exported action
		tell application "iSale 4"
			activate
			tell auction each
				
				if hitcount = 0 then
					set theTitle to (title)
					
				else if bidcount ≠ 0 then
					set theTitle to (title) & " @Sold"
					
				else
					set theTitle to (title) & " @Not"
				end if
				
			end tell
		end tell
		
		-- would cause saving problems
		set theTitle to searchReplace(theTitle, "/", "%")
		set theTitle to searchReplace(theTitle, ":", "%")
		
		-- do the saving
		tell application "System Events"
			tell process "iSale 4"
				
				click menu item "Auction." of menu 1 of menu item "Export" of menu 1 of menu bar item "File" of menu bar 1
				delay 1.5
				
				tell sheet 1 of window "iSale"
					keystroke "g" using {command down, shift down}
					delay 1
					tell sheet 1
						set value of text field 1 to "~/Documents/Save/iSale/" & theTitle
						delay 0.5
						click button "Go"
						delay 1
					end tell
					click button "Save"
					delay 2
				end tell
				
				keystroke (ASCII character 31)
				delay 3
				
			end tell
		end tell
	end repeat
	
	tell application "Finder"
		set NoOfFiles to count of (files in (entire contents of folder "Macintosh HD:Users:simon:Documents:Save:iSale:") whose name extension is "iSale")
	end tell
	tell application "iSale 4"
		display alert "The Backup Process has been finished! Number of Auctions saved: " & NoOfFiles
	end tell
	
	
else
	return
end if

(*
set T2 to minutes of (current date)
set T2s to seconds of (current date)
set TT_ to ((T2 * 60) + T2s) - ((T1 * 60) + T1s)

try
	set clipFil to (path to desktop folder as text) & "howmanyseconds.txt"
	try
		close access file clipFil
	end try
	set filRef to open for access file clipFil with write permission
	write (TT_ as text) to filRef starting at eof
	close access filRef
end try
*)

to searchReplace(this_text, search_string, replacement_string)
	set AppleScript's text item delimiters to the search_string
	set the item_list to every text item of this_text
	set AppleScript's text item delimiters to the replacement_string
	set this_text to the item_list as string
	set AppleScript's text item delimiters to ""
	return this_text
end searchReplace

Feel free to change to fit your needs, please post your modifications! Especially you will want to change this line

						set value of text field 1 to "~/Documents/Save/iSale/" & theTitle

and this

	set NoOfFiles to count of (files in (entire contents of folder "Macintosh HD:Users:simon:Documents:Save:iSale:") whose name extension is "iSale")

ah and on older Systems you may have to set higher delay times.

Enjoy!

simon

Model: Macbook 3.1
Browser: Firefox 2.0.0.14)
Operating System: Mac OS X (10.5)