Working Graphicconverter 'Set file iptc...' example please.

Hey guys,

You’ve been a great help recently between you all.

I was just wondering whether anyone can provide me a working example of the ‘Set file iptc’ command for graphicconverter to set the iptc caption.

I’ve been buggering around with it for ages now and still can’t make it happen.

Any help appreciated.

Regards,
Dan

See this thread and in particular, the link in it

Hey,

Thanks for the reply. I may be being a moron but i can’t find a code example of ‘set file iptc’ anywhere in there though?

Cheers,

Dan

Sorry, the first entry in that thread is all I know about it. Apparently Lemke provided some AppleScript, but I couldn’t get it to work for me.

Ok, cheers anyway.

I’ve spoken to Lemke on the GC forums aswell. TBH it doesn’t really appear he knows that much from an AS side as everything he’s said i can do to get round my problems has failed to help anyway.

Ah well, if i find a way to make it work i’ll report back and post it for others here.

Something like this usually works for me, drky:

set img_file to choose file of type {"public.image"} with prompt "Choose an image file:" without invisibles
tell application "GraphicConverter" to set file iptc img_file to {"enter", "your", "iptc", "values", "here."}

Excellent! But unfortunately I get: GraphicConverter got an error: alias “ACB-G5_1:Users:bellac:Pictures:Adam’s Pix 2005:DSC00379.JPG” doesn’t understand the set file iptc message unless I add this “as text”:

set img_file to (choose file of type {"public.image"} with prompt "Choose an image file:" without invisibles) as text
tell application "GraphicConverter" to set file iptc img_file to {"enter", "your", "iptc", "values", "here."}

If you want to check:

set img_file to (choose file of type {"public.image"} with prompt "Choose an image file:" without invisibles) as text
tell application "GraphicConverter"
	set file iptc img_file to {"enter", "your", "iptc", "values", "here."}
	get file iptc img_file
end tell

Weird. Since I’d been using GC v. 5.8.1, I was about to put that down to version differences. However, the alias form also works fine here in GC v. 5.9.4. :confused:

Thank you both for looking at this for me. I’ve felt like i’ve been banging my head against a wall for a couple of days.

My script now inserts the iptc captions (which is a huge step forward), now the only thing that i need to sort out is that when i insert a variable into one of the caption fields i get some weird formatting issue going on e.g.

"Vitalis Gardens$$JD1NV1L071.eps$$0107

What did you insert?

This script can come in handy for me. Thanks.
As is, It works fine (the one without as text) text appears in the file as it should.

My version for what I need goes like this (below):

It all seems to work,
But when it inserts the details Example ( this is my caption ) I get text like
Ok Tried to insert the text that I get back but it screwed the post?
so see image

Some where in my code the text gets changed from plain text? by the look of it.
Any Ideas, Thanks

set Caption to {"", "Caption", ""}
set Caption_writer to {"", "Caption writer", ""}
set Headline to {"", "Headline", ""}
set Instructions to {"", "Instructions", ""}
set Byline to {"", "Byline", ""}
set Byline_Title to {"", "Byline_Title", ""}
set Credit to {"", "Credit", ""}
set Source to {"", "Source", ""}
set title to {"", "title", ""}
set Unknown1 to {"", "", "unkown"}
set City to {"", "City ", ""}
set State to {"", "State", ""}
set Country to {"", "Country", ""}
set reference_ to {"", "reference", ""}
set Categories to {"", "Categories ", ""}
set Supplemetal_Categories to {"", "Supplemetal Categories", ""}
set Unknown2 to {"", "", "unkown", ""}
set Keywords to {"", "Keywords", ""}
set Copyright_notice to {"", "Copyright_notice", ""}
set _URL to {"", "URL", ""}
global indexer

set indexer to {Caption, Caption_writer, Headline, Instructions, Byline, Byline_Title, Credit, Source, title, Unknown1, City, State, Country, reference_, Categories, Supplemetal_Categories, Unknown2, Keywords, Copyright_notice, _URL}

repeat with i from 1 to number of items in indexer
	set this_item to item i of indexer
	if item 3 of this_item is "unkown" then
		set this_item to ""
	else
		display dialog "Enter : " & item 2 of this_item default answer "" buttons {"Cancel", "Done", "Next"} default button 3
		copy the result as list to {text_returned, button_pressed}
		set item 1 of this_item to text_returned as text
		
		if button_pressed is "Done" then
			
			my Set_cap()
			
			exit repeat
			
		else if button_pressed is "Next" and this_item is _URL then
			my Set_cap()
			
			exit repeat
			
		else if button_pressed is "Next" then
			
		end if
		
	end if
end repeat

on Set_cap()
	set indexer_a to {}
	repeat with i from 1 to number of items in indexer
		set this_itema to item i of indexer
		copy item 1 of this_itema to end of indexer_a
	end repeat
	set img_file to choose file of type {"public.image"} with prompt "Choose an image file:" without invisibles
	tell application "GraphicConverter" to set file iptc img_file to indexer_a
end Set_cap


edit** cleaned up script a bit, but still need the issue with the text to be sorted…

Thank you Jacques, That worked great. :slight_smile:

Here is the final script. (found a couple of more fields)

set Caption to {"", "Caption", ""}
set Caption_writer to {"", "Caption writer", ""}
set Headline to {"", "Headline", ""}
set Instructions to {"", "Instructions", ""}
set Byline to {"", "Byline", ""}
set Byline_Title to {"", "Byline_Title", ""}
set Credit to {"", "Credit", ""}
set Source to {"", "Source", ""}
set title to {"", "title", ""}
set Unknown1 to {"", "", "unkown"}
set City to {"", "City ", ""}
set State to {"", "State", ""}
set Country to {"", "Country", ""}
set reference_ to {"", "reference", ""}
set Categories to {"", "Categories ", ""}
set Supplemetal_Categories to {"", "Supplemetal Categories", ""}
set Unknown2 to {"", "", "unkown", ""}
set Keywords to {"", "Keywords", ""}
set Copyright_notice to {"", "Copyright_notice", ""}
set _URL to {"", "URL", ""}
set event_ to {"", "event_", ""}
set people to {"", "People", ""}
global indexer

set indexer to {Caption, Caption_writer, Headline, Instructions, Byline, Byline_Title, Credit, Source, title, Unknown1, City, State, Country, reference_, Categories, Supplemetal_Categories, Unknown2, Keywords, Copyright_notice, _URL, event_, people}

repeat with i from 1 to number of items in indexer
	set this_item to item i of indexer
	if item 3 of this_item is "unkown" then
		set this_item to ""
	else
		display dialog "Enter : " & item 2 of this_item default answer "" buttons {"Cancel", "Done", "Next"} default button 3
		copy the result as list to {text_returned, button_pressed}
		set item 1 of this_item to text_returned as string
		
		if button_pressed is "Done" then
			
			my Set_cap()
			
			exit repeat
			
		else if button_pressed is "Next" and this_item is people then
			my Set_cap()
			
			exit repeat
			
		else if button_pressed is "Next" then
			
		end if
		
	end if
end repeat

on Set_cap()
	set indexer_a to {}
	repeat with i from 1 to number of items in indexer
		set this_itema to item 1 of (get item i of indexer)
		if this_itema is not "" then
			set end of indexer_a to («class ktxt» of ((this_itema as string) as record))
		else
			set end of indexer_a to ""
		end if
	end repeat
	set img_file to choose file of type {"public.image"} with prompt "Choose an image file:" without invisibles
	tell application "GraphicConverter" to set file iptc img_file to indexer_a
end Set_cap

Hi There,

I get an error when trying to compile the script on this line


tell application "GraphicConverter" to set file iptc img_file to indexer_a
end Set_cap

at iptc img_file

Error “An identifier can’t go after this identifier”

Any Ideas?

Same here - same error.

I just re complied it from the post, no errors.
What version of GC are you using. I had to use 5.9.4 when I wrote this.

I’m using 5.9.4 as well, Mark.

This works perfectly:

set img_file to choose file of type {"public.image"} with prompt "Choose an image file:" without invisibles
tell application "GraphicConverter" to set file iptc img_file to {name:"ACBell"}

So the problem has to be with the record being passed.

LATER: Got it - if you press next but don’t enter anything in the next header, it bombs.

Comment: rather than key through them all, wouldn’t a recurring choose from list be better that kept letting you choose the data you wanted in the order you wanted it entering it each time in a dialog until you clicked “Done” on the choose from list or on the entry dialog.

Thats a good idea Adam, will play with that.

Strangely I’ve never got the bomb out when not entering the info and pressing Next?

Any way in the mean time here is the one I made for work.
It need to be save as a Application ( droplet. )


global indexer, biglist

on open these_items
	set biglist to {}
	process_items(these_items, biglist)
end open

on process_items(these_items, biglist)
	tell application "Finder"
		repeat with i from 1 to the count of the these_items
			set this_itemz to item i of the these_items
			copy this_itemz to end of biglist
		end repeat
	end tell
	set Caption to {"", "Caption", ""}
	set Caption_writer to {"", "Caption writer", ""}
	set Headline to {"", "Headline", ""}
	set Instructions to {"", "Instructions", ""}
	set Byline to {"", "Byline", ""}
	set Byline_Title to {"", "Byline_Title", ""}
	set Credit to {"", "Credit", ""}
	set Source to {"", "Source", ""}
	set title to {"", "title", ""}
	set Unknown1 to {"", "", "unkown"}
	set City to {"", "City ", ""}
	set State to {"", "State", ""}
	set Country to {"", "Country", ""}
	set reference_ to {"", "reference", ""}
	set Categories to {"", "Categories ", ""}
	set Supplemetal_Categories to {"", "Supplemetal Categories", ""}
	set Unknown2 to {"", "", "unkown", ""}
	set Keywords to {"", "Keywords", ""}
	set Copyright_notice to {"", "Copyright_notice", ""}
	set _URL to {"", "URL", ""}
	set event_ to {"", "event_", ""}
	set people to {"", "People", ""}
	set indexer to {Caption, Caption_writer, Headline, Instructions, Byline, Byline_Title, Credit, Source, title, Unknown1, City, State, Country, reference_, Categories, Supplemetal_Categories, Unknown2, Keywords, Copyright_notice, _URL, event_, people}
	
	repeat with i from 1 to number of items in indexer
		set this_item to item i of indexer
		if item 3 of this_item is "unkown" then
			set this_item to ""
		else
			display dialog "WARNING THIS WILL OVERWRITE EXISTING INFO" & return & return & "Enter : " & item 2 of this_item default answer "" buttons {"Cancel", "Done", "Next"} default button 3
			copy the result as list to {text_returned, button_pressed}
			set item 1 of this_item to text_returned as string
			
			if button_pressed is "Done" then
				
				my Set_cap(biglist)
				
				exit repeat
				
			else if button_pressed is "Next" and this_item is people then
				my Set_cap(biglist)
				
				exit repeat
				
			else if button_pressed is "Next" then
				
			end if
			
		end if
	end repeat
end process_items

on Set_cap(biglist)
	set indexer_a to {}
	repeat with i from 1 to number of items in indexer
		set this_itema to item 1 of (get item i of indexer)
		if this_itema is not "" then
			set end of indexer_a to («class ktxt» of ((this_itema as string) as record))
		else
			set end of indexer_a to ""
		end if
	end repeat
	invisibles
	
	repeat with i from 1 to number of items in biglist
		
		set this_item to item i of biglist
		set img_file to this_item as alias
		tell application "GraphicConverter" to set file iptc img_file to indexer_a
	end repeat
	
end Set_cap

I’m using version 5.7.1 of GraphicConverter. I checked it’s AS dictionary and set file iptc is in it but it still may be an issue. I’ll try 5.9.4

MT

Update: Works fine in GC 5.9.4

So here is the script with Adam’s idea of choosing the IPTC fields you want to enter first.
Let me know what you think, Cheers


global indexer, biglist

on open these_items
	set biglist to {}
	process_items(these_items, biglist)
end open

on process_items(these_items, biglist)
	tell application "Finder"
		repeat with i from 1 to the count of the these_items
			set this_itemz to item i of the these_items
			copy this_itemz to end of biglist
		end repeat
	end tell
	set Caption to {"", "Caption", ""}
	set Caption_writer to {"", "Caption writer", ""}
	set Headline to {"", "Headline", ""}
	set Instructions to {"", "Instructions", ""}
	set Byline to {"", "Byline", ""}
	set Byline_Title to {"", "Byline_Title", ""}
	set Credit to {"", "Credit", ""}
	set Source to {"", "Source", ""}
	set title to {"", "title", ""}
	set Unknown1 to {"", "", "unkown"}
	set City to {"", "City ", ""}
	set State to {"", "State", ""}
	set Country to {"", "Country", ""}
	set reference_ to {"", "reference", ""}
	set Categories to {"", "Categories ", ""}
	set Supplemetal_Categories to {"", "Supplemetal Categories", ""}
	set Unknown2 to {"", "", "unkown", ""}
	set Keywords to {"", "Keywords", ""}
	set Copyright_notice to {"", "Copyright_notice", ""}
	set _URL to {"", "URL", ""}
	set event_ to {"", "event_", ""}
	set people to {"", "People", ""}
	set itemlist to {}
	set indexer to {Caption, Caption_writer, Headline, Instructions, Byline, Byline_Title, Credit, Source, title, Unknown1, City, State, Country, reference_, Categories, Supplemetal_Categories, Unknown2, Keywords, Copyright_notice, _URL, event_, people}
	set indexer_Display_list to items 1 thru 9 of indexer & items 11 thru 16 of indexer & items 18 thru 22 of indexer as list
	repeat with i from 1 to number of items in indexer_Display_list
		set this_item to item i of indexer_Display_list
		copy item 2 of this_item to end of itemlist
	end repeat
	
	set indexer_choose to choose from list itemlist OK button name "Done" cancel button name "Exit" with prompt "Select IPTC Fields you'd like to set" with title "Choose IPTC Fields" with multiple selections allowed
	if indexer_choose is not false then
		repeat with i from 1 to number of items in indexer_choose
			set this_item_Of_indexer_choose to item i of indexer_choose
			
			display dialog "WARNING THIS WILL OVERWRITE EXISTING INFO" & return & return & "Enter : " & this_item_Of_indexer_choose default answer "" buttons {"Cancel", "Done", "Next"} default button 3
			copy the result as list to {text_returned, button_pressed}
			
			repeat with i from 1 to number of items in indexer
				set this_item_of_indexer to item i of indexer
				if item 2 of this_item_of_indexer is this_item_Of_indexer_choose then
					set item 1 of this_item_of_indexer to text_returned as string
				end if
			end repeat
			if button_pressed is "Done" then
				
				my Set_cap(biglist)
				
				exit repeat
				
			else if button_pressed is "Next" and this_item_Of_indexer_choose is last item in indexer_choose then
				my Set_cap(biglist)
				
				exit repeat
				
			else if button_pressed is "Next" then
				
			end if
			
		end repeat
	end if
end process_items

on Set_cap(biglist)
	set indexer_a to {}
	repeat with i from 1 to number of items in indexer
		set this_itema to item 1 of (get item i of indexer)
		if this_itema is not "" then
			set end of indexer_a to («class ktxt» of ((this_itema as string) as record))
		else
			set end of indexer_a to ""
		end if
	end repeat
	
	
	repeat with i from 1 to number of items in biglist
		
		set this_item to item i of biglist
		set img_file to this_item as alias
		tell application "GraphicConverter" to set file iptc img_file to indexer_a
	end repeat
	
end Set_cap

edit just fixed something…

Hi All,

This script works great! I was wondering though if there is a way to add more iptc fields to it. There are 20 custom fields and I would like to use some of them.

IPTC Field List
http://www.fotoware.com/binaries/fsp50/userguide/28.htm

Is this possible?

Thanks,
MarkT