Photoshop ??: save with new name & deleting masked area channel

Hello-
How would I go about naming a file when saving a Photoshop document?
I’m trying to save a file with the current name but with an appendage.

For example:
tell currentDocument
set name of currentDocument to fileName & “_layer”

Also -
What would be the best way to loop through the channels and delete any that are not component channels (CMYK, Cyan, Magenta, Yellow, Black)

thanks in advance!

You may want to use some lines from this:

tell application "Finder" to set myTempFileName to (home as string) & "Desktop:"
tell application "Adobe Photoshop CS"
	activate
	set display dialogs to never
	set ruler units of settings to pixel units
	set docRef to the current document
	set docName to name of docRef
	set docBaseName to getBaseName(docName) of me
	tell docRef
		delete (every channel whose kind is not component channel)
		set newFileName to myTempFileName & docBaseName & "_Apendage"
		save docRef in file newFileName as Photoshop format with options ¬
			{save layers:true} appending lowercase extension with copying
	end tell
	close current document without saving
end tell

on getBaseName(fName)
	set baseName to fName
	repeat with idx from 1 to (length of fName)
		if (item idx of fName = ".") then
			set baseName to (items 1 thru (idx - 1) of fName) as string
			exit repeat
		end if
	end repeat
	return baseName
end getBaseName

Thanks again!:smiley: