Extract part of this list and compare to another?

Hi All,

I have a list called myImages that looks like this:


{image id "0702-11_001.TIF" of favorite folder id "file://localhost/Volumes/Central%20Storage/Work%20Storage/0702-11%20Mazzios/Captures/" of session 2 of application "Capture One PRO", image id "0702-11_002.TIF" of favorite folder id "file://localhost/Volumes/Central%20Storage/Work%20Storage/0702-11%20Mazzios/Captures/" of session 2 of application "Capture One PRO", image id "0702-11_003.TIF" of favorite folder id "file://localhost/Volumes/Central%20Storage/Work%20Storage/0702-11%20Mazzios/Captures/" of session 2 of application "Capture One PRO", image id "0702-11_003a.TIF" of favorite folder id "file://localhost/Volumes/Central%20Storage/Work%20Storage/0702-11%20Mazzios/Captures/" of session 2 of application "Capture One PRO", image id "0702-11_004.TIF" of favorite folder id "file://localhost/Volumes/Central%20Storage/Work%20Storage/0702-11%20Mazzios/Captures/" of session 2 of application "Capture One PRO", image id "0702-11_005.TIF" of favorite folder id "file://localhost/Volumes/Central%20Storage/Work%20Storage/0702-11%20Mazzios/Captures/" of session 2 of application "Capture One PRO", image id "0702-11_006.TIF" of favorite folder id "file://localhost/Volumes/Central%20Storage/Work%20Storage/0702-11%20Mazzios/Captures/" of session 2 of application "Capture One PRO", image id "0702-11_007.TIF" of favorite folder id "file://localhost/Volumes/Central%20Storage/Work%20Storage/0702-11%20Mazzios/Captures/" of session 2 of application "Capture One PRO", image id "0702-11_008.TIF" of favorite folder id "file://localhost/Volumes/Central%20Storage/Work%20Storage/0702-11%20Mazzios/Captures/" of session 2 of application "Capture One PRO", image id "0702-11_009.TIF" of favorite folder id "file://localhost/Volumes/Central%20Storage/Work%20Storage/0702-11%20Mazzios/Captures/" of session 2 of application "Capture One PRO", image id "0702-11_010.TIF" of favorite folder id "file://localhost/Volumes/Central%20Storage/Work%20Storage/0702-11%20Mazzios/Captures/" of session 2 of application "Capture One PRO", image id "0702-11_011.TIF" of favorite folder id "file://localhost/Volumes/Central%20Storage/Work%20Storage/0702-11%20Mazzios/Captures/" of session 2 of application "Capture One PRO", image id "0702-11_012.TIF" of favorite folder id "file://localhost/Volumes/Central%20Storage/Work%20Storage/0702-11%20Mazzios/Captures/" of session 2 of application "Capture One PRO", image id "FolderSettings.plist" of favorite folder id "file://localhost/Volumes/Central%20Storage/Work%20Storage/0702-11%20Mazzios/Captures/" of session 2 of application "Capture One PRO"}

I need to compare the value of image id (i.e. 0702-11_001.TIF)of each item from myImages to the list imageName.
imageName looks like this:


{"0702-11_002.TIF", "0702-11_005.TIF", "0702-11_006.TIF", "0702-11_009.TIF"}

My script will be stepping though every item in myImages if it finds that the current item of myImages , called myImage, is in imageName then I want to perform a function otherwise perform another function.
I’m still struggling with lists but I’m sure it’s pretty easy for one of the masters;)

Here is a part of the code.


tell application "Capture One PRO"
	-- the session we're working on
	set mySession to session jobName
	-- get the images to process
	set myImages to every image of capture favorite folder of mySession
	-- set process target
	set myTarget to process destination "Web Proof"
	
	tell application "System Events" to tell process "Capture One PRO" -- enter the name of the target application process here
		set frontmost to true
		keystroke "2" using command down
	end tell
	tell application "System Events" to tell process "Capture One PRO" -- enter the name of the target application process here
		set frontmost to true
		key code 115 using command down
	end tell

	--Tag images from list ( THIS IS MY PROBLEM SECTION )
	repeat with myImage in myImages
		if myImage is in imageName then
			tell application "System Events" to tell process "Capture One PRO" -- this will tag the image if it is in imageName
				set frontmost to true
				keystroke "t" using command down -- Tags the image
key code 124 -- move to next image
			end tell
			
		else  -- if it's not in imageName
			tell application "System Events" to tell process "Capture One PRO"
				set frontmost to true
				keystroke "u" using command down -- Un-tag the image
				key code 124 -- move to next image
			end tell
		end if
	end repeat
	-- process image files
	repeat with myImage in myImages
		if tag of myImage is yes then
			start processing myImage target myTarget
		end if
	end repeat
end tell

I realize that without Capture One PRO you can’t really test this but I wanted to show how it is being used.
Thanks a bunch,
Mark

Hi Mark.

the problem is, that you try to compare an element (photo) with a string, which doesn’t work.
BTW: is Capture One such poorly scriptable, that everything must be done with GUI scripting? :wink:
try this, if image has a name property
repeat with myImage in myImages
if {name of myImage} is in imageName then

It appears so. I see a few complaints on the user forum for Capture One PRO that it lacks in it’s scriptability which is ironic because this app prides itself on workflow. The app has a dictionary. The dictionary for the app has a tag attribute and doesn’t say it is r/o, I’m assuming is read only, but I couldn’t get it to set the tag of an image to a value but I may not have been calling the image correctly. Here is the image section from the AS dictionary for the Capture One PRO Suite.

I have tried running it like this:


repeat with myImage in myImages
		if {name of myImage} is in imageName then
			tell application "System Events" to tell process "Capture One PRO"
				set frontmost to true
				keystroke "t" using command down
			end tell
			tell application "System Events" to tell process "Capture One PRO"
				set frontmost to true
				key code 124
			end tell
		else
			tell application "System Events" to tell process "Capture One PRO"
				set frontmost to true
				keystroke "u" using command down
				key code 124
			end tell
		end if
	end repeat

It steps through all the images like it should but doesn’t find any matches. I’m not sure about “name” but in the list myImages it has “image id” which contains the value I want to compare to. If I change “name” to “image id” in your example I get the following error
“Capture One PRO got an error: Can’t make id into type reference.”

Any thoughts?

Thanks for your fast reply!
Mark

WAIT! I got it. Your code was correct except that name needed to be id.


repeat with myImage in myImages
		if {id of myImage} is in imageName then
			tell application "System Events" to tell process "Capture One PRO"
				set frontmost to true
				keystroke "t" using command down
			end tell
			tell application "System Events" to tell process "Capture One PRO"
				set frontmost to true
				key code 124
			end tell
		else
			tell application "System Events" to tell process "Capture One PRO"
				set frontmost to true
				keystroke "u" using command down
				key code 124
			end tell
		end if
	end repeat

I have used Capture One PRO for years but have just started trying to script it so I’m not sure if it is the app’s lack of scriptibilty or my lack of scripting ability.:stuck_out_tongue: Probably the later but maybe both.

Thanks so much for your help,
Mark

I noticed, that image has a tag property, so you could set the tag directly without UI scripting

So maybe something like


set tag of image myImage to "Yes"

I tried it before but I don’t think I was getting the names compared so it just wasn’t finding anything to tag.
I’ll try it again. I may still need UI scripting to navigate through the images I guess as I don’t see anything in it’s dictionary involving navigating the images. I have to step through each image because the ones that aren’t in the list imageName I need to un-tag in case it was tagged previously.

Thanks,
Mark

When running this:


repeat with myImage in myImages
		if {id of myImage} is in imageName then
			tell application "System Events" to tell process "Capture One PRO"
				set frontmost to true
				--keystroke "t" using command down
				set tag of myImage to "Yes"
			end tell
			tell application "System Events" to tell process "Capture One PRO"
				set frontmost to true
				key code 124
			end tell
		else
			tell application "System Events" to tell process "Capture One PRO"
				set frontmost to true
				keystroke "u" using command down
				key code 124
			end tell
		end if
	end repeat

I get the error

Thanks,
Mark

try:

set tag of contents of myImage to "Yes"

setting a property of an element in a repeat loop works mostly with “contents of”

I tried this line

set tag of contents of myImage to "Yes"

but I get the error

Thanks,
Mark

next try

repeat with myImage in (get myImages)

¢ or
“Yes” must be in lower case “yes”
¢ or
try to get the tag, whether the reference error occurs, too

AppleScript is much trial an error :wink:

Well changing the repeat to

repeat with myImage in (get myImages)

gets the script to advance past the first image, which isn’t in the list, so the “else” clause is working but it hangs on the second image which is in the list so it still doesn’t like

set tag of contents of myImage to "yes"

I have tried a few variations of this line like:

set tag of myImage to yes
set tag of myImage to "yes"

but they error out.

I think this may be one issue. After reviewing the AS dictionary which shows it in lower case.

Here is a sample script from the developers of Capture One PRO


tell application "Capture One PRO"
	-- the session we're working on
	set mySession to session 1
	-- get the images to process
	set myImages to every image of capture favorite folder of mySession
	-- set process target
	set myTarget to process destination "High Quality"
	
	-- process image files
	repeat with myImage in myImages
		if tag of myImage is eight then
			start processing myImage target myTarget
		end if
	end repeat
end tell

They do not have any samples showing how to set a tag via AS. :frowning:

Thanks,
Mark