Hi All,
I have a library of images from an old iPhoto database which all have the creation date of “1 Jan 1970”. which is incorrect (obviously!!) BUT the folder structure they’re indicates the date they were added to iPhoto. I have written a script to extract the folder names to a date string but i’m getting and error :
“Can’t make {“28”, “/”, “05”, “/”,“2011”} into type date” when trying to concatenate the variables. Some help please with date formatting.
set myJpeg to choose file
set AliasPath to the result as text
set tids to AppleScript's text item delimiters
set AppleScript's text item delimiters to ":"
-- Determine how many folders are in the path string
set fldrcount to the (count of text items) of AliasPath
-- display dialog fldrcount
set fldrcount to fldrcount as integer
-- Get Year date from alias
set YearFldr to (fldrcount - 3) as integer
set YearDate to text items YearFldr through -4 of AliasPath
-- display dialog YearDate as string
-- Get Month date from alias
set MnthFldr to (fldrcount - 2) as integer
set MnthDate to text items MnthFldr through -3 of AliasPath
-- display dialog MnthDate as string
-- Get Day date from alias
set DayFldr to (fldrcount - 1) as integer
set DayDate to text items DayFldr through -2 of AliasPath
-- display dialog DayDate as string
set AppleScript's text item delimiters to tids
set NewCreateDate to {DayDate & "/" & MnthDate & "/" & YearDate} as date <- !! ERROR OCCURS HERE !!
display dialog NewCreateDate as string
tell application "Finder"
set the creation date of myJpeg to NewCreateDate as date
end tell
SAMPLE REPLY FROM SCRIPT EDITOR:
tell application “Script Editor”
choose file
→ alias “Data:Projects:Development:Applescript:MacPro:iPhoto batch creation date:Sample images:2011:05:28:DSC01065.JPG”
Result:
error “Can’t make {"28", "/", "05", "/", "2011"} into type date.” number -1700 from {“28”, “/”, “05”, “/”, “2011”} to date
Thanks in Advance.
Model: MBP 2013 15"
AppleScript: 2.4
Browser: Safari 600.7.12
Operating System: Mac OS X (10.10)