I am trying to incorporate an exiftool command into an Applescript routine that performs complex image manipulations. The following routine is aimed at modifying the creation dates and modification dates of the image files moved to a directory after manipulation.
I would like to use the classic exiftool command:
exiftool "-filemodifydate<datetimeoriginal" "-filecreatedate<datetimeoriginal" DIR
However the directory is named by the script with the command :
set pTargetFoldername to "Edited-pictures" & space & date string of (current date) & space & time of (current date) as string
.
And therefore the directory name contains spaces.
My routine AdjustDates
does not work. The resulting command does not compensate for the spaces and cannot be used in a “do shell script cmd” call The command created (with the dates in the local french language) is :
"/usr/local/bin/exiftool -filemodifydate<datetimeoriginal -filecreatedate<datetimeoriginal '/Users/yves/Desktop/Edited-Pictures mercredi 31 juillet 2024 70545'"
I do not seem to see a solution which should seem trivial.
on AdjustDates(pTargetFolderPath)
tell application "Finder"
set ThePath to (POSIX path of pTargetFolderPath)
end tell
set exiftool_path to "/usr/local/bin/exiftool"
set exiftool_args to "-filemodifydate<datetimeoriginal" & space & "-filecreatedate<datetimeoriginal"
set cmd to exiftool_path & space & exiftool_args & space & (quoted form of ThePath)
return cmd --for test only
--do shell script cmd -- not functional due to the spaces in the directory path
end AdjustDates