AppleScript Help Needed: Save 1 .psd as 7 web-ready .jpegs

Newbie to AppleScript but not to Photoshop. Trying to expedite tedious, repetitive tasks for more efficiency. Working in Photoshop CC 2014, RGB document with masks (as separated channels) that I am writing a script to: load seven separated channels as seven separate selections, crop to the selection seven times and export / save the seven selections as separate web-ready .jpegs. I have scoured the Internet and have come up with this:

tell application "Adobe Photoshop CC 2014"
	tell current document
		load selection of it from channel 5 of it
		set theCropBounds5 to bounds of selection
		crop bounds theCropBounds5
		set myFile to "OS X 10.8.5 US:Users:myName:Desktop:myBanners"
		set myOptions to {class:JPEG save options, embed color profile:true, format options:standard, matte:background color matte, quality:12}
		save current document in file myFile as JPEG with options myOptions
	end tell
end tell

Loading the channel and cropping to the selection works fine but I think my export / saving commands (and perhaps file set up, too) are incomplete and probably inaccurate because the script throws an error at “save current document”: “Adobe Photoshop CC 2014 got an error: File/Folder expected” number 1230"

Would love direction on 2 things: 1- how to write the script so that the selections will save as separate files and 2 - how to repeat this code for all 7 selections in one script (for efficiency’s sake). Thanks!

Model: MacBook Pro
Browser: Safari 537.36
Operating System: Mac OS X (10.8.5)

The saving part will work (or at least works in CS6) if you move the second-to-last “end tell” to just before the “save current document” line, so that you’re telling the app to save the document.

Everything you are trying to do should be possible as an Action/Droplet within Photoshop. Applescript isn’t necessary here.

Thank you for the suggestion. I was actually able to work around using AppleScript and have been exporting assets from complex, layered Photoshop files with the “Extract Assets” tool - guess I missed that during one of the releases! Still curious to learn more about AppleScript but, now, at a more leisurely pace. Thanks!!

Hi, there!

I’m sorry, but why you want to save your channels as separate documents?
I think you need create a different layers with contents and masked them with different layer mask. Next you can save your layers as a different jpeg/png/pdf/tif/gif-files with names same as layers names.