Le script crée un répertoire par album et y exporte les photos / vidéos. Donc ça n'exporte pas les photos qui ne sont pas dans un album, mais il existe des outils pour s'assurer que toutes les photos sont bien dans un album avant si vous voulez.
Pour les vidéos, ça chie pas mal car iPhoto les gère de manière un peu différente
C'est très probablement buggé dans certaines conditions (notamment pour les vidéos) et assurément mal codé, mais ça a le mérite de fonctionner avec mon iPhoto.
A un moment j'avais voulu faire la même chose un peu plus proprement en parsant le contenu du fichier AlbumData.xml, mais en sh c'est chaud de parser un XML ou alors je ne connais pas les bons outils.
-- Script d'export pour iPhoto, © Sébastien Schuller, 2006 -- ce script crée un répertoire par album et y copie toutes les images correspondantes -- permet de faire des sauvegardes lisibles par un PC Windows, ou pour de-switcher -- choix pour l'utilisateur du répertoire de sauvegarde tell application "Finder" set main_output_folder to choose folder with prompt "Select output folder" end tell tell application "iPhoto" -- récupération de la liste des albums set album_list to every album -- boucle pour chaque album repeat with i from 1 to the count of album_list set current_album to the item i of album_list set album_name to the name of current_album set test to the type of current_album -- seulement pour les vrais albums (IE pas la phototèque, pas la dernière pellicule ...) if test is equal to regular album then -- création du répertoire pour l'album tell application "Finder" -- purge des caractères interdits set album_name to my fct_remplacer(album_name as string) -- si le répertoire n'existe pas, on le crée 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 -- répertoire pour l'export set album_folder to folder album_name of main_output_folder end tell -- pour chaque image de l'album set album_photos to every photo of the current_album repeat with j from 1 to the count of album_photos set current_photo to the item j of album_photos set photo_file to (POSIX file (image path of current_photo as string)) as string set k_list to every keyword of current_photo set top_video to 0 repeat with z from 1 to the count of k_list set current_keyword to the item z of k_list set mot to the name of current_keyword if mot = "Séquence" then set top_video to 1 end if end repeat if top_video = 1 then -- traitement spécial vidéo set orig_Name to current_photo's name --As long as you haven't changed the name (title) of the image, this should return the name of the non-JPG file set orig_Path to current_photo's image path set astid to AppleScript's text item delimiters set AppleScript's text item delimiters to "Modified" try set new_Path to (text item 1 of orig_Path) & "Originals" & (text item 2 of orig_Path) set AppleScript's text item delimiters to "/" set new_Path to ((text items 1 thru -2 of new_Path) & orig_Name) as string end try set AppleScript's text item delimiters to astid set photo_file to (POSIX file (new_Path)) as string end if -- fin spécial vidéo --copie de la photographie tell application "Finder" duplicate photo_file to album_folder with replacing end tell end repeat end if end repeat end tell on fct_remplacer(input) -- remplacer les occurences de caractères interdits dans les noms de dossier sous Windows -- on remplace les / des dates dans les noms d'album: interdit sous Windows set text item delimiters of AppleScript to "/" set Lst to text items of input set text item delimiters of AppleScript to "-" set input to Lst as text return input end fct_remplacer