iView Media script problem
iView Media script problem
- Subject: iView Media script problem
- From: Hellum Timothy <email@hidden>
- Date: Mon, 28 Apr 2003 07:42:15 -0400
Hello all,
I am using iView Media Pro to catalog a whack of jpegs and am using a
script that ships with it to mate a tab-delim text file to that library of
images. After IPTC field population, I "synchronize" those fields back into
the images' actual IPTC headers.
I have adapted the script slightly as I am accessing a tab-delim file from
Eyewire instead of PhotoDisc (Getty bought PhotoDisc, then Getty bought
Eyewire, so text file formats have changed slightly since the script was
written I think). I have included a snippet of the tab-delim file below the
script.
The script runs through the contents of the items in the text file, but
does not populate the IPTC fields (via the "import_annotations(theFolder)"
command) in the iView library. I have run this script through Script
Debugger in debug and step mode, but cannot find the source of the problem.
Any ideas?
<SCRIPT>
property theFilename : ""
property theDescription : ""
property theKeywords : ""
property theKeywordsList : {}
on run
if can_run() = false then return
if about_script() = "Cancel" then return
-- locate the CDROM folder
set theFolder to ""
set diskList to list disks
repeat with i from 1 to number of items in diskList
tell application "Finder"
try
set theFolder to item i of diskList &
":RESOURCES:TEXT:" as alias
exit repeat
end try
end tell
end repeat
if theFolder = "" then ,
set theFolder to (choose folder with prompt "Is this the Tab-delim
text file?")
-- import annotations
tell application "iView MediaPro"
set the cursor to 7
end tell
import_annotations(theFolder)
tell application "iView MediaPro"
set the cursor to 0
end tell
end run
--
on import_annotations(rootFolder)
set textFolder to rootFolder as text
tell application "Finder"
set fileList to every file of folder textFolder
end tell
repeat with tx from 1 to number of items in fileList
annotate_media(item tx of fileList as text)
end repeat
end import_annotations
--
on annotate_media(textFile)
tell application "Finder"
set refNum to open for access file textFile
if refNum = 0 then return
end tell
set x to get_next_line(refNum) -- skip the 1st line
set i to 1 -- get all other lines
repeat while get_next_line(refNum) = true
tell application "iView MediaPro"
set the cursor to 14
tell window 1
try
set theID to the index of the first object
whose name is theFilename
tell object theID
set theRecord to the annotations
set the caption of theRecord to
theCaption & " <-- Eyewire Image# " & theDescription
set the headline of theRecord to
"Eyewire - Weekends"
set the credit of theRecord to
")Eyewire"
set the keywords of theRecord to
theKeywordsList
set annotations to theRecord
end tell
end try
end tell
end tell
set i to i + 1
end repeat
tell application "iView MediaPro" to set the |cursor| to 0
tell application "Finder"
close access refNum
end tell
end annotate_media
--
on get_next_line(refNum)
try
tell application "Finder"
set theLine to read refNum before return
end tell
on error
return false
end try
-- parse the line
set AppleScript's text item delimiters to tab
set theFilename to text item 1 of theLine
set theDescription to text item 2 of theLine
set theKeywords to text item 3 of theLine
set AppleScript's text item delimiters to ""
-- parse the keywords list
set theKeywordsList to {}
if theKeywords contains "" then
set AppleScript's text item delimiters to ""
else
set AppleScript's text item delimiters to ","
end if
set theKeywordsList to every text item of theKeywords
set AppleScript's text item delimiters to ""
return true
end get_next_line
--
on about_script()
display dialog ,
"Go find your Tab-delim text file!" buttons {"Cancel", "OK..."}
default button 2 with icon note
set theAnswer to the button returned of the result
return theAnswer
end about_script
--
on can_run()
tell application "iView MediaPro"
if (exists window 1) then return true
end tell
display dialog "Oops! You gotta have a library of images open first!"
buttons ,
{"Darn!"} default button 2 with icon note
return false
end can_run
</SCRIPT>
<TAB-DELIM SNIPPET>
Filename Description Keywords
WEE_001R.JPG Woman and man in-line skating on pathway
Caucasian,couple,female,fitness,friend,friendship,husband,in-line,in-line
skating,inline,inline
skating,leisure,male,man,men,outdoor,outside,people,recreation,skater,skatin
g,sports,wife,woman,women
WEE_002R.JPG Mother and daughter sitting and smiling, father giving son
piggyback ride
boy,brother,carrying,Caucasian,child,children,couple,cuddling,dad,daughter,f
amilies,family,father,female,girl,husband,kid,love,male,man,men,mom,mother,o
utdoor,outside,parent,people,piggyback,piggyback
ride,ride,sister,smiling,son,wife,wives,woman,women
WEE_003R.JPG Mother sleeping, holding baby on chest
affection,African,African-American,babies,baby,black,bonding,boy,child,child
ren,cuddling,daughter,families,family,female,girl,holding,indoor,infant,insi
de,kid,love,mom,mother,Mother's
Day,multicultural,napping,parent,people,single,single
parent,sleeping,son,woman,women
</TAB-DELIM SNIPPET>
---------------------------------------------------------------
"Our lives begin to end the day we
become silent about things that matter"
Dr. Martin Luther King, Jr
---------------------------------------------------------------
The Globe and Mail
Canada's National Newspaper
Editorial IT Support
(416) 585-5168
www.globeandmail.ca
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.