Renommer les images d’un dossier avec ses données exifs

Written by

Voici un AppleScript qui peut être utilisé dans Automator pour renommer tous les fichiers d’un dossier de photos en utilisant les données EXIF sélectionnées à partir d’une liste déroulante:

-- Set the property to the chosen EXIF data
set theProperty to choose from list {"Date Time Original", "Make", "Model"} with prompt "Choose the EXIF data to use for renaming:"

-- Check if a property was chosen
if theProperty is not false then
    -- Set the property to the first item in the list (since choose from list returns a list)
    set theProperty to item 1 of theProperty
    
    -- Set the folder path
    set folderPath to (choose folder with prompt "Choose the folder containing the photos:") as text
    
    -- Get the list of files in the folder
    tell application "Finder"
        set fileList to every file of folder folderPath
    end tell
    
    -- Loop through each file in the list
    repeat with aFile in fileList
        -- Get the file path
        set filePath to aFile as text
        
        -- Get the EXIF data for the chosen property
        set exifData to do shell script "mdls -raw -name kMDItem" & theProperty & " " & quoted form of POSIX path of filePath
        
        -- Check if EXIF data was found
        if exifData is not "" then
            -- Rename the file using the EXIF data
            tell application "Finder"
                set name of aFile to exifData & "." & name extension of aFile
            end tell
        end if
    end repeat
end if

Ce script vous permet de choisir les données EXIF à utiliser pour renommer les fichiers à partir d’une liste déroulante. Vous pouvez ajouter ou supprimer des options de la liste en modifiant la première ligne du script. Est-ce que cela répond à vos besoins?