Photoshop Color Mode using IF statement

I’m trying to process folders full of TIFF files. Some are bitmap, color or grayscale. I don’t want to process the bitmap files and am trying to test the color mode and if they are bitmap, just close the file and move on to the next one.

I don’t think I have the syntax correct on my if statement because the script is processing all files.

on run
	with timeout of 36000 seconds
		set sourcePath to choose folder with prompt "Please select SOURCE folder:"
		tell application "Finder" to set fileList to (files of entire contents of sourcePath whose size > 1 and name ends with ".tif") as alias list
		repeat with aFile in fileList
			
			tell application "Adobe Photoshop CS6"
				activate
				open file (aFile as string)
				set theMode to mode of current document
				set possibleModes to {"bitmap"}
				if possibleModes is theMode then
					close current document
				else
					set myOptions to {class:TIFF save options, byte order:IBM PC, image compression:LZW}
					save current document as TIFF in (aFile as string) with options myOptions appending lowercase extension with replacing
					close current document
				end if
			end tell
		end repeat
		end timeout
	activate
	display dialog "LZW Script is done"
	
end run

Hi,

bitmap is an enumerated constant “ without quotes “ and you have to check if the possibleModes list contains the mode of the current document.
The timeout block is needed only for the Finder part and it’s not necessary to activate Photoshop and define the mode list in each iteration of the loop


set sourcePath to choose folder with prompt "Please select SOURCE folder:"
with timeout of 36000 seconds
	tell application "Finder" to set fileList to (files of entire contents of sourcePath whose size > 1 and name ends with ".tif") as alias list
end timeout
tell application "Adobe Photoshop CS6"
	activate
	set possibleModes to {bitmap}
	repeat with aFile in fileList
		open file (aFile as string)
		set theMode to mode of current document
		if possibleModes does not contain theMode then
			set myOptions to {class:TIFF save options, byte order:IBM PC, image compression:LZW}
			save current document as TIFF in (aFile as string) with options myOptions appending lowercase extension with replacing
		end if
		close current document
	end repeat
end tell
display dialog "LZW Script is done"

You’re a lifesaver. Thank You!