et
An even more personal Windows Batch script that works with the aim of streamlining some EXIF prunings I regularly perform; it of course requires exiftool to be downloaded and put into %PATH%, with these switches listed as follows could be passed to the script to carry out their corresponding tasks:
-a: removes all EXIF information from the given file;-c: replicates all EXIF information from the reference file to the given file;-d: aligns all date and time tags in the given file with the 『CreateDate』 tag from the reference file;-g: removes all GPS-related information from the given file;-i: removes ICC Profile information from the given file;-p: removes some (but not all) fields of information injected by Photoshop from the given file; and-r: removes rotation and size–related information from the given file.
The first three switches observe a descending order of precedence where switches in the upper level will surpass the lower ones if more than one is detected; the other four switches are in the same lowest level, and therefore they can be used simultaneously but shall be surpassed by any one of the upper three.
The pursuit of a reference file follows the following logic—
The batch script will first try to find a file with the same filename and extension in a set of directories pre-defined in the script (from %p1% to %pa%); if such a file cannot be found, it will then try to search in the current directory for a file bearing the basename created from the input filename stripped of both extension and potential suffix induced by either a hyphen (-) or an underscore (_) and concatenated with a set of pre-defined extensions (from %x1% to %xc%); if no such file can be reached, it will then continue the pursuit by using the input filename without extension concatenated with the said set of extensions to traverse the said set of paths, and if such a file still cannot be found, it will then make its last effort by using the two patterns aforesaid of stripped basenames to traverse the said set of paths to try find such a file.
Both this logic and the sets of paths and extensions are quite personal and are therefore not suitable for general application without tailored adaptation.
A REG file is attached below to integrate these commonly used exiftool commands with the shell on Windows.
The batch
@echo off
chcp 65001 >nul
setlocal enabledelayedexpansion
set "p1=D:\Photos\"
set "p2=..\"
set "p3=D:\"
set "p4=D:\New folder\"
set "p5=D:\1\"
set "p6=D:\Omnigena\"
set "p7=D:\Omnigena\New folder\"
set "p8=D:\Omnigena\1\"
set "p9=D:\Images\"
set "pa=D:\Images\_WebImages\"
set "x1=.jpg"
set "x2=.dng"
set "x3=.arw"
set "x4=.srf"
set "x5=.sr2"
set "x6=.srw"
set "x7=.crw"
set "x8=.cr2"
set "x9=.cr3"
set "xa=.nef"
set "xb=.nrw"
set "xc=.heic"
set "a="
set "c="
set "d="
set "f="
set "g="
set "i="
set "l="
set "p="
set "r="
set "t="
set "ib="
set "id="
set "in="
set "ip="
set "iu="
set "rf="
:a
if /i "%~1"=="" goto p
set "a=%~1"
if /i "!a:~0,1!"=="-" (
if /i "%a%"=="-a" set "l=1"
if /i "%a%"=="-c" set "c=1"
if /i "%a%"=="-d" set "d=1"
if /i "%a%"=="-g" set "g=-GPS*= "
if /i "%a%"=="-i" set "i=-ICC_Profile= "
if /i "%a%"=="-p" set "p=-Document*= -*id= -History*= -PhotoshopThumbnail= -CreatorTool= -Software= -IPTC= -IPTCDigest= -GlobalAngle= -GlobalAltitude= -XResolution= -DisplayedUnitsX= -YResolution= -DisplayedUnitsY= -ResolutionUnit= "
if /i "%a%"=="-r" set "r=-exifimagewidth= -exifimageheight= -orientation= -rotation= "
if /i "%a%"=="-t" set "t=-ifd1:all= -PreviewImage= -padding= -thumb*= "
) else (
if not defined f set "f=%~1"
)
shift
goto a
:p
if not defined f goto e
for %%F in ("%f%") do set "in=%%~nxF" & set "ib=%%~nF" & set "ip=%%~pF"
for /f "tokens=1 delims=-" %%D in ("%ib%") do set "id=%%D"
for /f "tokens=1 delims=_" %%U in ("%ib%") do set "iu=%%U"
if /i "%ip%"=="\" (
for %%P in (p1 p4 p5 p6 p7 p8 p9 pa) do (
if exist "!%%P!!in!" (
set "rf=!%%P!!in!"
goto c
)
)
) else (
for %%P in (p1 p2 p3 p4 p5 p6 p7 p8 p9 pa) do (
if exist "!%%P!!in!" (
set "rf=!%%P!!in!"
goto c
)
)
)
if /i not "%id%"=="%in%" if /i not "%id%"=="%ib%" (
for %%X in (x1 x2 x3 x4 x5 x6 x7 x8 x9 xa xb xc) do (
if exist ".\%id%!%%X!" (
set "rf=.\%id%!%%X!"
goto c
)
)
)
if /i not "%iu%"=="%in%" if /i not "%iu%"=="%ib%" (
for %%X in (x1 x2 x3 x4 x5 x6 x7 x8 x9 xa xb xc) do (
if exist ".\%iu%!%%X!" (
set "rf=.\%iu%!%%X!"
goto c
)
)
)
if /i "%ip%"=="\" (
for %%P in (p1 p4 p5 p6 p7 p8 p9 pa) do (
for %%X in (x1 x2 x3 x4 x5 x6 x7 x8 x9 xa xb xc) do (
if exist "!%%P!!ib!!%%X!" (
set "rf=!%%P!!ib!!%%X!"
goto c
)
)
)
) else (
for %%P in (p1 p2 p3 p4 p5 p6 p7 p8 p9 pa) do (
for %%X in (x1 x2 x3 x4 x5 x6 x7 x8 x9 xa xb xc) do (
if exist "!%%P!!ib!!%%X!" (
set "rf=!%%P!!ib!!%%X!"
goto c
)
)
)
)
if /i "%ip%"=="\" (
for %%P in (p1 p4 p5 p6 p7 p8 p9 pa) do (
for %%X in (x1 x2 x3 x4 x5 x6 x7 x8 x9 xa xb xc) do (
if exist "!%%P!!id!!%%X!" (
set "rf=!%%P!!id!!%%X!"
goto c
)
)
)
) else (
for %%P in (p1 p2 p3 p4 p5 p6 p7 p8 p9 pa) do (
for %%X in (x1 x2 x3 x4 x5 x6 x7 x8 x9 xa xb xc) do (
if exist "!%%P!!id!!%%X!" (
set "rf=!%%P!!id!!%%X!"
goto c
)
)
)
)
if /i "%ip%"=="\" (
for %%P in (p1 p4 p5 p6 p7 p8 p9 pa) do (
for %%X in (x1 x2 x3 x4 x5 x6 x7 x8 x9 xa xb xc) do (
if exist "!%%P!!iu!!%%X!" (
set "rf=!%%P!!iu!!%%X!"
goto c
)
)
)
) else (
for %%P in (p1 p2 p3 p4 p5 p6 p7 p8 p9 pa) do (
for %%X in (x1 x2 x3 x4 x5 x6 x7 x8 x9 xa xb xc) do (
if exist "!%%P!!iu!!%%X!" (
set "rf=!%%P!!iu!!%%X!"
goto c
)
)
)
)
:c
if defined l (
exiftool -overwrite_original -all= "%f%"
) else if defined c (
exiftool -overwrite_original -TagsFromFile "%rf%" "-all:all>all:all" "%f%"
exiftool -overwrite_original -xmptoolkit= "%f%"
) else if defined d (
exiftool -overwrite_original -TagsFromFile "%rf%" "-CreateDate>DateTimeOriginal" "-CreateDate>CreateDate" "-CreateDate>DateTime" "-CreateDate>CreationTime" "-CreateDate>ModDate" "-CreateDate>ModifyDate" "-CreateDate>FileModifyDate" "-CreateDate>DateAcquired" "-CreateDate>FileCreateDate" "-CreateDate>MetadataDate" -xmptoolkit= "%f%"
) else if /i not "%g%%i%%p%%r%%t%"=="" (
exiftool -overwrite_original %g%%i%%p%%r%%t%-xmptoolkit= "%f%"
)
:e
endlocal
The REG file
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\SystemFileAssociations\image\shell\1RMA]
@="Remove all EXIF data"
[HKEY_CLASSES_ROOT\SystemFileAssociations\image\shell\1RMA\command]
@="\"C:\\_c\\et.bat\" \"%1\" -a"
[HKEY_CLASSES_ROOT\SystemFileAssociations\image\shell\2RPA]
@="Replicate EXIF data from original"
[HKEY_CLASSES_ROOT\SystemFileAssociations\image\shell\2RPA\command]
@="\"C:\\_c\\et.bat\" \"%1\" -c"
[HKEY_CLASSES_ROOT\SystemFileAssociations\image\shell\3EPS]
"MUIVerb"="Further EXIF pruning"
"SubCommands"=""
[HKEY_CLASSES_ROOT\SystemFileAssociations\image\shell\3EPS\shell]
[HKEY_CLASSES_ROOT\SystemFileAssociations\image\shell\3EPS\shell\31RMI]
@="Remove ICC profile"
[HKEY_CLASSES_ROOT\SystemFileAssociations\image\shell\3EPS\shell\31RMI\command]
@="\"C:\\_c\\et.bat\" \"%1\" -i"
[HKEY_CLASSES_ROOT\SystemFileAssociations\image\shell\3EPS\shell\32RMP]
@="Remove SOME Ps-injected data"
"CommandFlags"=dword:00000040
[HKEY_CLASSES_ROOT\SystemFileAssociations\image\shell\3EPS\shell\32RMP\command]
@="\"C:\\_c\\et.bat\" \"%1\" -p"
[HKEY_CLASSES_ROOT\SystemFileAssociations\image\shell\3EPS\shell\33RM3]
@="Do all the following at once"
"CommandFlags"=dword:00000040
[HKEY_CLASSES_ROOT\SystemFileAssociations\image\shell\3EPS\shell\33RM3\command]
@="\"C:\\_c\\et.bat\" \"%1\" -g -r -t"
[HKEY_CLASSES_ROOT\SystemFileAssociations\image\shell\3EPS\shell\34RMG]
@="Remove GPS data"
[HKEY_CLASSES_ROOT\SystemFileAssociations\image\shell\3EPS\shell\34RMG\command]
@="\"C:\\_c\\et.bat\" \"%1\" -g"
[HKEY_CLASSES_ROOT\SystemFileAssociations\image\shell\3EPS\shell\35RMT]
@="Remove thumbnail images"
[HKEY_CLASSES_ROOT\SystemFileAssociations\image\shell\3EPS\shell\35RMT\command]
@="\"C:\\_c\\et.bat\" \"%1\" -t"
[HKEY_CLASSES_ROOT\SystemFileAssociations\image\shell\3EPS\shell\36RMR]
@="Remove rotation and size info"
[HKEY_CLASSES_ROOT\SystemFileAssociations\image\shell\3EPS\shell\36RMR\command]
@="\"C:\\_c\\et.bat\" \"%1\" -r"
[HKEY_CLASSES_ROOT\SystemFileAssociations\image\shell\4RPD]
@="Align all DeT tags with original"
[HKEY_CLASSES_ROOT\SystemFileAssociations\image\shell\4RPD\command]
@="\"C:\\_c\\et.bat\" \"%1\" -d"