how can I copy the modification date of (media)files from the original files to the converted ones

Hi,

i have a little problem and I hope that maybe someone could help me out on that.


I have recently migrated my whole Windows photos library into Photos using PowerPhotos. Since there are some file types Photos cannot import I had to extract these files using the log files of the import. I have converted those to mp4.

But the converting files do not retain the modification date which Photos uses to sort the photos based on the dates. I dont want to go through each file one by one and change the date in Photos.


I could not find an app that would do something like batch-altering the metadata of files on macOS using other files metadata as a blueprint.


Because I am not a programmer I have tried to use ChatGTP to write Terminal/AppleScript-Codes but it does not seem to work out. The approach was to look up the modification dates of the unconverted files and overwriting the ones of the converted files. The names are exactly the same.


here is an example of a code ChatGPT came up with


set sourceFolderPath to "/Users/.../Downloads/AVIoriginal"

set destinationFolderPath to "/Users/.../Downloads/AVIconverted"



tell application "System Events"

	set fileList to name of every file in folder sourceFolderPath

end tell



repeat with fileName in fileList

	set sourceFilePath to sourceFolderPath & fileName

	set destinationFilePath to destinationFolderPath & fileName

	

	set modificationDate to modification date of (info for sourceFilePath)

	
	set yearString to text -4 thru -1 of ("0000" & (year of modificationDate) as text)

	set monthString to text -2 thru -1 of ("00" & (month of modificationDate) as text)

	set dayString to text -2 thru -1 of ("00" & (day of modificationDate) as text)

	set hourString to text -2 thru -1 of ("00" & (hours of modificationDate) as text)

	set minuteString to text -2 thru -1 of ("00" & (minutes of modificationDate) as text)

	

	do shell script "touch -t " & quoted form of (yearString & monthString & dayString & hourString & minuteString) & " " & quoted form of destinationFilePath

end repeat


I can manually type in the touch command for each file in terminal but this is also not a solution.


Maybe someone has a sparkling idea :D ?



Posted on May 7, 2024 12:42 AM

Reply
9 replies

May 7, 2024 7:52 AM in response to YNoel2000

My workflow is to always copy internal metadata date to the filename with GraphicConverter (or with A Better Finder Rename, exiftool etc).


Then if I re-encode the movie, I preserve the date in the re-encoded filename and maybe add a suffix like 2024-0507-1750-00_converted.mp4. And then copy that filename to the internal metadata date with the apps above. exiftool can copy all or selected metadata from the original to the re-encoded movie.


See also:


Movie dates and Photos.app - Apple Community



May 8, 2024 4:30 AM in response to YNoel2000

Which system version is running on your Mac? Could you upgrade the Mac to Sonoma, if it is running an older system version?

On a Mac with macOS 14.4 the videos will use the capture date as the file creation date, when you export them from Photos, the original video files as well as the modified files.


We had to wait a long time for this feature, but now it is much easier to archive our media files by exporting them from Photos.

See the user tip: New in Photos 9 on macOS 14 Sonoma: Exporting Photos or Videos from Photos is now saving them with the date taken as the creation date


If we change the date of an item in Photos, the modified date taken will be used as the file creation date, even if the date is centuries in the past.

May 8, 2024 10:27 AM in response to léonie

Thanks for your answer.


Because I didn't export the library from the Photos app but from Windows (normal folder tree structure) I didn't had that functionality. But I didn't know the feature so thank you.


And through the converting process (because some files were incompatible with Photos) new files were created which (of course) didn't retain the correct dates. I found a solution through ExifTool (see answer below).


Additionally I used osxphotos to change some dates in the Photos App (so that the modification date becomes the taken date; some photos didn't had the right date) by using


osxphotos timewarp --pull-exif --use-file-time


I have another question on your script Script: Add the Album Name as a keyword t… - Apple Community

Should it still work? I want to add the album name(s) as a keyword to the photos in the album/album tree (like picture.jpg is in album 2003->January->3. birthday so it should get the keywords 2003, January,3. birthday) but I can't get the script to work.


osxphotos should also work but that's a little beyond my skill.

how can I copy the modification date of (media)files from the original files to the converted ones

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.