More than a year ago, I wrote the tutorial how to add date time stamp to JPEG photos like old P&S film camera could do. It has been one of the most popular articles on this blog.
Many people requested different formats for the date time stamp. In the original script, the format is set by the ImagaMagick software and it is not directly changeable. However with a few simple modifications to the script, customization of the format can be achieved.
IF NOT DEFINED _cmd SET _cmd=blank
IF %_cmd%==? GOTO :help
IF %_cmd%==/? GOTO :help
FOR /R %%G IN (*.jpg) DO CALL :process "%%G"
IF %_choice%==3 EXIT /B
if NOT %_str%==%1 EXIT /B
IF /I NOT "%_cmd%"=="ADDDT" GOTO :report %1
IF NOT %_choice%==4 CALL :ask %1
IF %_choice%==2 EXIT /B
IF %_choice%==3 ECHO Cancelling, please wait ... && EXIT /B
CALL :sum %1
identify -format %%w %_inname% >dttmpfile
set /p width=
ECHO Processing %_inname% ...
FOR /F "tokens=1,2,3,4,5,6 delims=: " %%a IN ('identify -format "%%[EXIF:DateTimeOriginal]" %_inname%') DO SET year=%%a&set month=%%b&set day=%%c&set hour=%%d&set min=%%e&set sec=%%f
set DTString="%month%/%day%/%year% %hour%:%min%:%sec%"
convert %_inname% -gravity NorthWest -font "Digital-7-Italic" -pointsize %pointsize% -fill white -annotate +%pointsize%+%pointsize% %DTString% %_outname%
CHOICE /C YNCA /M "Process %~1 (Yes, No, Cancel, All)?"
CALL :sum %1
ECHO Found %1
SET /A _bytes+=%~z1/1000
SET /A _count+=1
IF %_bytes%==0 (ECHO No files processed) ELSE (ECHO %_count% matching files, %_bytes%KB)
ECHO DTSTAMP [ADDDT]
ECHO Batch adding Date and Time stamp to all jpg files in the current directory.
ECHO New file with name (original name)_DT.jpg will be generated.
ECHO Run command with ADDDT option to actually process jpg files, otherwise the command only list the files that will be affected.
ECHO !! No warranty expressed or implied !!
ECHO !! Use at your own risk !!
- The date time format is now by default “DD/MM/YYYY HH:MM:SS”. The format is configured by line 33. You can change it based on your need.
- The new version will skip files that have already had the date time stamp added. If you run the script more than once, the previously stamped files (with “_DT” added in their names) will be over written.
- If you want to change the location of the date time stamp, check out line 34. The location is specified by the string after “-gravity”. NorthWest is top left and SouthEast is bottom right, etc.
If you have problem copying the script directly from above, you can download it here: DTStampV2
Keywords: Date Time Stamp, exif, Metadata