AppleScript to tag listings which use "USPS First Class Package"

I keep seeing the warnings in eBay US that I “must” change listings with First Class Package shipping to be USPS Ground Advantage. This is a lot of listings, for me, so I spent a few minutes to write a script to help me find them.

  • select the listings first
  • the script will check any Shipping Option to see if it’s “USPS First Class Package”; it doesn’t have to be the first you’ve assigned
  • it will add a blue tag if the listing does match, and will remove the color tag (entirely!) from any listing that does not match
  • you can use a Smart Group to collect all listings that do have a blue tag, for further editing
  • obviously you can edit this to find the string searched for, if you need to re-use for other purposes

Note that the entire script includes the handlers "on makeMyChange" and "on clearMyChange", not just the "tell application" part.

on makeMyChange(thisListing)
	tell application "GarageSale"
		set the tag of thisListing to 6
	end tell
end makeMyChange

on clearMyChange(thisListing)
	tell application "GarageSale"
		set the tag of thisListing to 0
	end tell
end clearMyChange

tell application "GarageSale"
	repeat with theListing in (get selected ebay listings)
		set shippy to (the shipping option of theListing)
		
		tell shippy
			set serviceNames to {}
			repeat with thisItem in its ebay shipping service
				set end of serviceNames to (the service name of thisItem)
			end repeat
		end tell
		
		if (serviceNames contains "USPS First Class Package") then
			my makeMyChange(theListing)
		else
			my clearMyChange(theListing)
		end if
		
	end repeat
end tell