Friday, December 15, 2017

#1 2011-07-13 06:31:48 pm

scott6210
Member
Registered: 2011-07-09
Posts: 2

How assign new keyword to every 3.5 GB of photos

I am a newbie to Apple, Mac, and Applescript, and am only a hobbyist scripter with Apple.  I've scripted in Perl and UNIX before, but that's it.  i've searched the forums and archives of MacScripter but not found an answer to my specific problem (that I could recognize - of course, I'm a newbie to MacScripter too!).

I want to burn DVDs of all my photos, which means I need to divide them into 3.5 GB sets (or a bit larger).  I used to group them in separate folders on Windows, but I'd like to use iPhoto to track them and don't want to have a duplicate set in folders too. I thought a good way to do it would be to assign the DVD name as a keyword to each 3.5 of photos, then export all photos with that keyword and burn to DVD.  Keywords would be something like "DVD_A", "DVD_B", "DVD_C", etc.  I want to automate this for future imports of photos, so that as it imports them, it checks to see how many GB there are in the last keyword, fills it up to 3.5 GB, then starts assigning to the next keyword, etc. 

If there is a better way to do it within iPhoto, I'd be happy to use that.  Otherwise, I'm hoping someone on MacScripter can help me with the script.  Here's all I have so far (not much!):

property theFolder : "the:name:of:the:photo:folder"
try
    tell application "Finder" to set theFiles to files of folder theFolder
    repeat with oneFile in theFiles
        tell application "iPhoto"
            import from (oneFile as alias)
        end tell
    end repeat
end try

1.  I don't know how to get iPhoto to give me the size of the image so I can start totaling it up.

2.  I know I can't create keywords in iPhoto (according to an Applescript forum entry I saw) so I would create the keywords in advance ("DVD_A", "DVD_B", "DVD_C", etc.).  But then I don't know how to find the last-used keyword in the list, and find how much space its files already take.

If that is too complicated a task for a simple Applescript, I can use Perl to group the images/videos to be imported into folders whose name IS the keyword (DVD_A, etc.).  Perl could also ensure each folder will have no more than 3.5 GB of photos in it.  Then the Applescript can just assign the keyword that matches the Folder name, and I'll delete folders as soon as they're fully imported.

3.  Also, there may be photos in the folder that have already been imported, and so I want to tell iPhoto to skip importing duplicates.  Is that a parameter I can set?

Lastly, sorry for not knowing how to really say these things.  Don't have the lingo yet.

Scott

Offline

 

#2 2011-08-08 10:46:34 am

ame
Member
Registered: 2011-06-28
Posts: 151

Re: How assign new keyword to every 3.5 GB of photos

A better method should be (without use iPhoto):

Scan your folder/s and generate using AppleScript a tab text file for ALL your images with 4 fields:

Image File Name
Pathname
Size of file in KB
Original Creation Date as YYYMMDDD

After sort all by date using Excel on field Original Creation Date (from older to newest)

After using Applescript and Exiftool process files for max 4360 MB (size of a DVD) and inject as Keyword the name of DVD (DVD_1, DVD_2, DVD_3...)

Is not very difficult but if you are AS beginner this can be like climb Everest ;-)

Stefano

Offline

 

#3 2011-08-13 07:18:22 pm

scott6210
Member
Registered: 2011-07-09
Posts: 2

Re: How assign new keyword to every 3.5 GB of photos

Thanks for replying, Stefano!  I appreciate your help.  I like your suggestion.  Since my first post, I've done something much like your suggestion; using Perl.  I've written a Perl program to pull the photos off the SD card, renumber them and group them into folders with ~3.5GB in them.  I can burn them to a DVD directly from those folders and do not need to export them from iPhoto, so my main need for the keyword is gone.

I still want to automate the import to iPhoto because I'm trying to make it as automatic as possible for my wife, who's not very computer-literate.  It would be nice to have the keyword on the photos too, so I would know which DVD had the original photo on it.  Here's my code to import the photos, using the folder name as the keyword.  It picks the last folder, but I plan to change it to give the user a list of folders to choose from.

If iPhoto can import keywords from the photo's EXIF header, I could write the keyword into the photo with Perl before importing it.  Can it do that?

Applescript:

property theFolder : "Macintosh HD:Users:scott:Desktop:iPhoto_Staging_Folder"
--try
tell application "Finder" to set theFolders to folders of folder theFolder
set lastFolder to last item of theFolders
set nameOfLastFolder to name of lastFolder
display dialog nameOfLastFolder buttons "OK"
tell application "iPhoto"
   import from (lastFolder as alias) with force copy -- "force copy true" leaves the photos in their original folder and makes a copy. I still must find a way to exclude duplicates somehow, so I don't import same photo twice and give the second copy a different keyword
   select all in event nameOfLastFolder as event
   assign keyword nameOfOneFile
end tell

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)