Garage Sale picture idea

I looked at this, thinking it would be easy to do with a couple of AppleScript files. It turned, we needed to patch GarageSale to cope with tightened macOS sandbox restrictions.

So, once you have downloaded GS 9.8 Beta 6 (GarageSale 9.8 Alpha 6 Released), you can give this AppleScript a go.

It lets you pick a folder, and every JPEG image at the top level of this folder will get turned into a listing in GarageSale with that image.
Every subfolder in the folder you picked will get turned into a listing, too, having all images it contains added.

Confusingly, GarageSale might ask you to pick that folder once again, that work around sandbox reading restrictions.

Paste this into Script Editor:

use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions

tell application "Finder"
	set theFolder to (choose folder)
	set theFiles to (name of every file in theFolder)
	try
		set theFolders to (name of every folder in theFolder)
	on error
		display alert "No folders were found in the selected folder"
		error number -128
	end try
end tell

set theFolderPath to theFolder as string

repeat with theFile in theFiles
	if the theFile ends with ".jpeg" or theFile ends with ".jpg" then
		set fileAlias to (theFolderPath & theFile) as alias
		createListing(theFile as string, {fileAlias})
	end if
end repeat

repeat with aFolder in theFolders
	set folderAlias to (theFolderPath & aFolder) as alias
	set imageFileAliases to {}
	tell application "Finder"
		set imageFiles to (name of every file in folderAlias)
		repeat with imageFileName in imageFiles
			set imageAlias to ((folderAlias as string) & imageFileName) as alias
			set imageFileAliases to imageFileAliases & imageAlias
		end repeat
	end tell
	createListing(aFolder as string, imageFileAliases)
end repeat


on createListing(listingName, images)
	tell application "GarageSale"
		set theListing to make ebay listing
		tell theListing
			set title to listingName
			repeat with theImageFile in images
				if (the theImageFile as string) ends with ".jpeg" or (the theImageFile as string) ends with ".jpg" then
					set imagePath to POSIX path of theImageFile
					set theImage to make listing image file imagePath
				end if
			end repeat
		end tell
	end tell
end createListing

Let me know how it works for you.

1 Like