loop through folders and write date with EXIFTool

I have these recovered photo’s from my old website and saved them from Photoshop > save for the web, so no EXIF data is present.
My photos are in folders with the date names like so:

images
2004-05-25
DSCN1379.jpg
DSCN1383.jpg
DSCN1395.jpg
2004-05-26
DSCN1402.jpg
DSCN1405.jpg

So now I would like to take the the date from the folder name and write that into the EXIF as ‘Date Time Original’

I had a look at the command line from EXIFTool and for my folders I can write the dates to the photo’s with:
exiftool -overwrite_original -DateTimeOriginal=“2004:05:25 00:00:00” desktop/test/try/2004-05-25/*.jpg

Can anyone help me with this?
Thanks for any help!

Model: MacBook Pro
AppleScript: 2.2
Operating System: Mac OS X (10.5)

Hi,

I don’t use EXIFTool, so I can’t test it.


set theFolder to choose folder with prompt "choose images target folder"

set thePictures to paragraphs of (do shell script "find " & quoted form of POSIX path of theFolder & " -iname '*.jpg'")
set TID to text item delimiters
repeat with onePicture in thePictures
	try
		set text item delimiters to "/"
		set theDate to text item -2 of onePicture
		set text item delimiters to "-"
		set theDate to text items of theDate
		set text item delimiters to ":"
		set theDate to theDate as text
		do shell script "exiftool -overwrite_original -DateTimeOriginal=\"" & theDate & " 00:00:00\" " & quoted form of onePicture
	end try
end repeat
set text item delimiters to TID

:slight_smile:

Thank you so much Stefan, I just tested it on a copy and it worked like charm.
You can’t believe how happy I am, over 1000 photo’s EXIF-ed!

Greets from Italy