Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'An AppleScript to export iPhoto into SimpleViewer' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
An AppleScript to export iPhoto into SimpleViewer
Authored by: kevin_C on Oct 24, '05 11:11:45AM

I attempted, but could not get success. The script returns an error-"NSCannotCreatScriptCommand"- are there version requirements? I have older iPhoto... as I am a novice at scripting/flash/xml, I do not know how to de-bug...



[ Reply to This | # ]
NSCannotCreateScript Error fixed!
Authored by: finnpage on Nov 12, '05 05:05:52PM

I was having the same error. I have iPhoto 4 and OS X 10.3.9
I finally found a fix by changing two lines in the script referring to the POSIX path of the image and thumbnail files. I also changed the caption from the title of the picture to the caption of the photo. Here is the new version of the script.

[code]
tell application "iPhoto"

set album_name to name of current album
tell application "Finder"
set main_output_folder to choose folder with prompt "Please select output folder"
end tell

tell application "Finder"
if not (exists folder album_name of main_output_folder) then
make new folder at main_output_folder with properties {name:album_name}
end if

set album_name to folder album_name of main_output_folder

if (not (exists folder "thumbs" of album_name)) then
make new folder at album_name with properties {name:"thumbs"}
end if

if (not (exists folder "images" of album_name)) then
make new folder at album_name with properties {name:"images"}
end if
end tell


set album_photos to every photo of the current album

set output to "<?xml version='1.0' encoding='UTF-8'?><SIMPLEVIEWER_DATA maxImageDimension='800' textColor='0xFFFFFF' frameColor='0xFFFFFF' bgColor='0x181818' frameWidth='20' stagePadding='20' thumbnailColumns='2' thumbnailRows='5' navPosition='right' navDirection='LTR' title='" & name of current album & "' imagePath='" & name of current album & "/images/' thumbPath='" & name of current album & "/thumbs/'>" & return

repeat with i from 1 to the count of album_photos

set my_photo to item i of album_photos

-- ****** next two lines are new
set photo_path to (image path of my_photo)
tell application "Finder" to set photo_file to ((POSIX file photo_path) as alias)
set photo_filename to image filename of my_photo

-- ****** next two lines are new
set thumb_path to (thumbnail path of my_photo)
tell application "Finder" to set thumb_file to ((POSIX file thumb_path) as alias)
set thumb_filename to thumbnail filename of my_photo


tell application "Finder"
set thumbs_folder to folder "thumbs" of album_name

if (exists item thumb_filename of thumbs_folder) then
delete item thumb_filename of thumbs_folder
end if

if (exists item photo_filename of thumbs_folder) then
delete item photo_filename of thumbs_folder
end if

duplicate thumb_file to thumbs_folder
set name of (file thumb_filename of thumbs_folder) to photo_filename

set new_thumb to (file photo_filename of thumbs_folder) as string

tell application "Image Events"
close images
set thisImage to open new_thumb
scale thisImage to size 60
save thisImage
end tell

set photo_folder to folder "images" of album_name

if (not (exists item photo_filename of photo_folder)) then
duplicate photo_file to photo_folder with replacing
end if

set new_photo to (file photo_filename of photo_folder) as string
tell application "Image Events"
close images
set thisImage to open new_photo
scale thisImage to size 800
save thisImage
end tell

end tell

-- ****** 'comment' was 'title'
set output to output & "<image><name>" & photo_filename & "</name><caption>" & comment of my_photo & "</caption></image>" & return as string

end repeat

set output to output & "</SIMPLEVIEWER_DATA>" & return as string


set output_filename to album_name as text
set output_filename to output_filename & "imageData.xml"

my write_to_file(output as string, output_filename, false)


end tell

on write_to_file(this_data, target_file, append_data)
try
set the target_file to the target_file as text
set the open_target_file to open for access file target_file with write permission
if append_data is false then set eof of the open_target_file to 0
write this_data to the open_target_file --starting at eof
close access the open_target_file
return true
on error
try
close access file target_file
end try
return false
end try
end write_to_file
[/code]

Matt



[ Reply to This | # ]
NSCannotCreateScript Error fixed!
Authored by: mr Grinners on Jan 11, '06 04:24:37AM

Sorry to be ignorant never really done the script editing before but which script do you need to edit? the app itself? or do you create a new script? (which i tried and tested and works fine) but how do i get this to work with the iphotoexport app???

Thanks

Damien



[ Reply to This | # ]
NSCannotCreateScript Error fixed!
Authored by: mr Grinners on Jan 11, '06 05:23:05AM

I got the script working now but cant get the photos to load properly, keeps coming up with what looks js errors and the photos dont load into the viewer properly..... any ideas???

Cheers



[ Reply to This | # ]