iView home page
iView Multimedia Forum Index

FAQ FAQ     SearchSearch     MemberlistMemberlist     UsergroupsUsergroups    RegisterRegister  
ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

"Keywords to Description"-Script

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    iView Multimedia Forum Index -> AppleScript
View previous topic :: View next topic  
Author Message
goolaf



Joined: 28 Feb 2006
Posts: 19

PostPosted: Sun Feb 11, 2007 12:17 am    Post subject: "Keywords to Description"-Script Reply with quote

My problem is: Using an external keyword-editor I created a deep keyword-hierarchy with many, many highly specific keywords. As I do many photocomposing that is really necessary. ;-) Unfortunately I wrote that keywords into the IPTC-keywordfield instead of the description-field. So now in iView I have a way too long keyword-list and also in every other programm (like Aperture which offers keywordtrees) the keywordlist is too cluttered.
I think it's a good idea to move all those picture-specific keywords separated by commas into the descriptionfield and use the keyword-field for a more general, slimmer tagging of the image. By now I have over 10000 pictures. Is there a possibilty to do the trick automatically in iView?

Could somebody here help me out with a script for this task? I really know nothing of scripting until now. :oops:
In some pictures I have already some text in the description field, so that the keywords should be appended to the existing info rather than overwriting it. I hope this is possible and I'd very appreciate any help from you.
Best regards
Olaf
Back to top
View user's profile Send private message
goolaf



Joined: 28 Feb 2006
Posts: 19

PostPosted: Sun Feb 11, 2007 12:03 pm    Post subject: Reply with quote

I tried to modify the script from here

I changed the lines to

set myName to the keywords of theItem as text
set caption of theItem to myName

This obviously works, but it overwrites existing descriptions and writes all keywords without comma or space into the captionfield. How I can I change that? Can someone please help me?
Regards
Olaf[/url]
Back to top
View user's profile Send private message
goolaf



Joined: 28 Feb 2006
Posts: 19

PostPosted: Sun Feb 11, 2007 9:38 pm    Post subject: Reply with quote

In case somebody needs something like this, too: After a night and a day of try and error I found the solution for my problem. I adapted this script to my needs.

on run
set selectedItems to GetSelection()
AboutScript()
tell window 1 of application "iView MediaPro"
repeat with theItem in selectedItems

set keywordList to keywords of theItem
set NewCaption to the caption of theItem & ", " & my ASCII_Sort(keywordList)
set the caption of theItem to NewCaption

end repeat
end tell
end run

on GetSelection()
set selectedItems to {}
tell application "iView MediaPro"
if catalog 1 exists then set selectedItems to the selection of catalog 1
end tell
if number of items in selectedItems is 0 then
display dialog
"You need to select at least one media item in the current catalog in order to use this script." buttons {"OK"} default button
"OK" with icon note giving up after 10
error number -128
end if
return selectedItems
end GetSelection

on AboutScript()
display dialog
"SOrt keywords and write into caption?." buttons {"Cancel", "OK"} default button 2
with icon note giving up after 10
set theAnswer to the button returned of the result
return theAnswer
end AboutScript

-- ASCII_Sort sub-routine --
on ASCII_Sort(my_list)
set the index_list to {}
set the sorted_list to {}
repeat (the number of items in my_list) times
set the low_item to ""
repeat with i from 1 to (number of items in my_list)
if i is not in the index_list then
set this_item to item i of my_list as text
if the low_item is "" then
set the low_item to this_item & ", "
set the low_item_index to i
else if this_item comes before the low_item then
set the low_item to this_item & ", "
set the low_item_index to i
end if
end if
end repeat
set the end of sorted_list to the low_item
set the end of the index_list to the low_item_index
end repeat
return the sorted_list as text
end ASCII_Sort
Back to top
View user's profile Send private message
vseh



Joined: 01 Apr 2004
Posts: 133
Location: Sydney, Australia

PostPosted: Fri Dec 28, 2007 9:22 pm    Post subject: Reply with quote

Hi
You seem to have had a similar problem to me.
I'd like to put the keywords into the description box. The current script (below) inserts all the keywords just as I've entered them (which is what I want ) but doesn't leave any spaces between words. How do I get a space, so that the description is readable?

on run

-- get the list of selected ID's in front window
set selectedItems to GetSelection()

-- show about
AboutScript()

-- process each item
tell window 1 of application "iView MediaPro"
repeat with theItem in selectedItems

set theInfo to the keywords of theItem

set theText to " "

if theInfo ≠ "" then set theText to theText & theInfo & return



if theText ≠ "" then set the caption of theItem to theText
end repeat
end tell


end run


-- get the selected media items in an array ---------------------------------------------

on GetSelection()
set selectedItems to {}
tell application "iView MediaPro"
if catalog 1 exists then set selectedItems to the selection of catalog 1
end tell
if number of items in selectedItems is 0 then
display dialog
"You need to select at least one media item in the front catalog in order to use this script." buttons {"OK"} default button
"OK" with icon note giving up after 10
error number -128
end if
return selectedItems
end GetSelection


-- about this script ---------------------------------------------

on AboutScript()
display dialog
"This command creates a new caption for each selected media item, using available keywords." buttons {"Cancel", "OK"} default button 2 with icon note
set theAnswer to the button returned of the result
return theAnswer
end AboutScript



Many thanks for any help.
_________________
Shawn Richards
Powerbook17"MacBook Pro, Mac OS 10.5 and IVMP 3.1.3 and Canon 20D
Back to top
View user's profile Send private message
Daniel



Joined: 01 May 2004
Posts: 119
Location: France

PostPosted: Sat Dec 29, 2007 9:09 am    Post subject: Reply with quote

Hi Shawn,

With this subroutine you convert every list (like keywords) to text with the separator of your choice.
Code:
on ListToText(TheList, Separator)
   set AppleScript's text item delimiters to Separator
   set X to TheList as string
   set AppleScript's text item delimiters to ""
   return X
end ListToText

example:
Code:
...
set theInfo to the keywords of theItem
set theInfo to ListToText(theInfo, ", ")
set the caption of theItem to theInfo
...
Back to top
View user's profile Send private message Visit poster's website
vseh



Joined: 01 Apr 2004
Posts: 133
Location: Sydney, Australia

PostPosted: Sat Dec 29, 2007 12:11 pm    Post subject: Reply with quote

Thanks Daniel,
Unfortunately I have to admit to total ignorance of programming and scripting. This might have to wait till a rebirth
Whilst I have a vague feel for what the above is meant to do, I've tried for a couple of hours to insert it into the original script but with no success.
Further help please!
PS Your scripting contributions are gratefully acknowledged, are they available on the expression media site or only IVMP?
_________________
Shawn Richards
Powerbook17"MacBook Pro, Mac OS 10.5 and IVMP 3.1.3 and Canon 20D
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    iView Multimedia Forum Index -> AppleScript All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



  © iView Multimedia Ltd. | All Rights Reserved Privacy Policy | Copyright | Site Map