wysocki Posted 5 hours ago Posted 5 hours ago (edited) Modern cameras and cellphones include a lot of data about photos taken into the image as EXIF data, which includes exposure info, GPS coordinates, and exposure date/time. In many file operations (moving, editing, etc) the dates don't reflect the real time of exposure, this script fixes that. To use this script you'll have to first install the app from exiftool.org onto your computer. This script simply allows you to select a folder and it grabs the date/time from all the JPGs in it and changes their file created and modified dates to correspond to the EXIF date. Pretty basic, but just adjust the code as you like! expandcollapse popup;PROCESS JPG IMAGES IN A SELECTED FOLDER WITH EXIFTOOL TO RETRIEVE SHOOTING DATE AND REWRITES FILE DATES. ;SCANS A DIRECTORY FOR IMAGES AND SETS THE DATES CREATED AND MODIFIED FROM THE EXIF SHOOTING DATE ;The EXIFTOOL app needs to be downloaded from https://exiftool.org/ (then adjust its folder name below) #include <autoitconstants.au3> #include <MsgBoxConstants.au3> $dirname = FileSelectFolder('Select a Folder','') Local $hSearch = FileFindFirstFile($dirname & "\*.jpg") If $hSearch = -1 Then ; Check if the search was successful. MsgBox($MB_SYSTEMMODAL, "", "Error: No JPG files were found in that folder.") exit EndIf Local $imagefile = "", $iResult = 0 local $arr[1] = ['JPG with EXIF GPS - ' & $dirname] SplashTextOn("EXIF DATE CHECK...", "Setting DATE MODIFIED from EXIF in images...",400,100,500,100) While 1 $imagefile = FileFindNextFile($hSearch) ; If there is no more file matching the search. If @error Then ExitLoop $pid = Run(@ComSpec & " /c " & 'd:\apps\exiftool.exe -DateTimeOriginal ' & $dirname & '\' & $imagefile, "", @SW_HIDE, 2) ProcessWaitClose($pid) $sOutput = StringMid(StdoutRead($pid),35) $sOutput = StringRegExpReplace($sOutput,'[: ]','') ConsoleWrite("EXF: " & $sOutput & @CRLF) ;Commment out the fields you don't want to be updated... FileSetTime($dirname & '\' & $imagefile,$sOutput, 0) ;SET FILE MODIFIED TIME TO SHOOTING TIME FROM EXIF FileSetTime($dirname & '\' & $imagefile,$sOutput, 1) ;SET FILE CREATED TIME TO SHOOTING TIME FROM EXIF ; FileSetTime($dirname & '\' & $imagefile,$sOutput, 2) ;SET FILE ACCESSED TIME TO SHOOTING TIME FROM EXIF ConsoleWrite('UPDATED:' & @CRLF) ConsoleWrite('MOD: ' & FileGetTime($dirname & '\' & $imagefile, 0, 1) & @CRLF) ConsoleWrite('CRE: ' & FileGetTime($dirname & '\' & $imagefile, 1, 1) & @CRLF) ConsoleWrite('ACC: ' & FileGetTime($dirname & '\' & $imagefile, 2, 1) & @CRLF) ControlSetText('EXIF DATE CHECK...', "", "Static1", $dirname & '\' & $imagefile & ' ' & $sOutput) WEnd FileClose($hSearch) splashoff() msgbox(64,'Done','File date processing completed.') Edited 4 hours ago by wysocki
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now