scripting dropzip / stuffit to batch jpg's added to folder

Afternoon all,

has anyone found a way of applescripting aladdin systems dropzip or stuffit?

When I try to record the functions from either of these two packages, nothing (other than opening) records?

My goal, was a folder action, that could convert .jpg’s added to a folder, convert them to .zip format and sling them into a folder called… you’ve guessed it… Zips!

Any thoughts anyone?

Az

wilse,

One way is to download Leonard Rosenthal’s Stuffit Commands

http://www.lazerware.com/software.html

I tried to set up a folder action but it would fail, lock up the folder actions server, and force me to reboot. Feel free to try the script - in theory it should work as I removed the code from the folder action handler and just ran it as a script. It worked fine.

on adding folder items to theFolder after receiving theAddedItems
	--define the path to your Zip folder
	
	set zipFolder to "Mac HD:Desktop Folder:Zips:"
	repeat with thisItem in theAddedItems
		tell application "Finder"
			set thisItemName to the name of file thisItem
		end tell
		set thisItemZipped to zipFolder & thisItemName & ".zip" as string --define the path to the file that will be the Zip File
		set ZipYou to Zip thisItem into thisItemZipped --zip the file, compression level can be set to anywhere between 0 and 9, default is 6
	end repeat
end adding folder items to

Here’s my suggestion. Instead of a folder action, which requires the folder to be open when you add the items, compile one of the following scripts and save it as a stay-open script. It will check the folder every 3 seconds for items, or however long you want between checks.

I wasn’t sure by reading your post just how many files were in each zip. All files dropped, or each having its own zip file. So.

--do this if you want to zip each jpeg into its own zip file
on idle
	set archiveFolder to "Mac HD:Desktop Folder:Archived JPEGs:" --define the path to your Archive folder(where your jpegs will go once zipped
	set dropFolder to "Mac HD:Desktop Folder:DropFolder:" --define the path to your Drop folder(where you drop the files
	set zipFolder to "Mac HD:Desktop Folder:Zips:" --define the path to your Zip folder (Your zipped files will go here)
	
	tell application "Finder"
		set droppedItemNames to get the name of every item of folder dropFolder --list the folder
	end tell
	if the number of items in droppedItemNames > 0 then --there's stuff in there
		tell application "Finder"
			set theAddedItems to every item of folder dropFolder --get the items in the folder
		end tell
		repeat with thisItem in theAddedItems
			tell application "Finder"
				set thisItemName to the name of thisItem --get the name of the item we are zipping
			end tell
			set thisItemZipped to zipFolder & thisItemName & ".zip" as string --define the path to the file that will be the Zip File
			set ZipYou to Zip thisItem into thisItemZipped --zip the file, compression level can be set to anywhere between 0 and 9, default is 6
		end repeat
		tell application "Finder"
			move theAddedItems to folder archiveFolder --move the originals to the archive folder
		end tell
	else
		return 3 --check back in 3 seconds.  Adjust if need be
	end if
end idle

or

--do this if you want to zip all the files you just dropped into the folder into one zip file
on idle
	set archiveFolder to "Mac HD:Desktop Folder:Archived JPEGs:" --define the path to your Archive folder(where your jpegs will go once zipped
	set dropFolder to "Mac HD:Desktop Folder:DropFolder:" --define the path to your Drop folder(where you drop the files
	set zipFolder to "Mac HD:Desktop Folder:Zips:" --define the path to your Zip folder (Your zipped files will go here)
	
	tell application "Finder"
		set droppedItems to get the name of every item of folder dropFolder --list the folder
	end tell
	if the number of items in droppedItems > 0 then --there's stuff in there
		tell application "Finder"
			set theAddedItems to every item of folder dropFolder --get the items we are going to zip
			set thisItemName to "ZippedFile.zip" --you can set the name of the archive to whatever you want here
			set thisItemZipped to zipFolder & thisItemName as string --define the path to the file that will be the Zip File
			set ZipYou to Zip theAddedItems into thisItemZipped --zip the file, compression level can be set to anywhere between 0 and 9, default is 6
			move theAddedItems to folder archiveFolder --move the originals to the archive folder
		end tell
	else
		return 3 --check back in 3 seconds.  Adjust if need be
	end if
end idle

If you do this I recommend getting info on the saved application and boosting the preferred memory size a little to reduce the risk of memory errors.

I know it isn’t exactly what you asked for but I hope it helps. Maybe someone will read this and let me know why my folder action wouldn’t work.

Best of luck,

Okay, I got it.

If you really want a folder action instead of a stay open script I figured out the error.

on adding folder items to theFolder after receiving theAddedItems
	--define the path to your Zip folder
	set zipFolder to "TWS-0103:Desktop Folder:Zips:"
	repeat with thisItem in theAddedItems
		set thisItem to thisItem as alias--I was missing this, had to define each as an alias instead of a referenced item
		tell application "Finder"
			set thisItemName to the name of file thisItem
		end tell
		set thisItemZipped to zipFolder & thisItemName & ".zip" as string --define the path to the file that will be the Zip File
		set ZipYou to Zip thisItem into thisItemZipped --zip the file, compression level can be set to anywhere between 0 and 9, default is 6
	end repeat
end adding folder items to