I'm trying to get some EXIF data added to the filenames in a folder. So far, I've been able to get the smaller pieces to work, but I can't get the name and extension separated so the can be combined with the EXIF values via the FOR loop.
I saw that I need to use !
to delineate the variable in the loop, but I can't get this to work with the filename.
SETLOCAL ENABLEDELAYEDEXPANSION
for /f "tokens=* delims=" %%a in ('dir /b *') do (
set file=%%~a
set _fname=%~n1
set _ext=%~x1
for /f %%i in ('exiftool.exe -s -S -SourceImageWidth %file%') do set WIDTH=%%i
for /f %%i in ('exiftool.exe -s -S -SourceImageHeight %file%') do set HEIGHT=%%i
for /f %%i in ('exiftool.exe -s -S -CompressorID %file%') do set CODEC=%%i
rename %file% "%_fname% [%WIDTH%x%HEIGHT% %CODEC%]%_ext%"
)
The process is: get filename -> get name only -> get extension -> get EXIF values -> rename file with values added to name and reuse extension -> repeat on next file in current directory
I apologize for the sloppy batch syntax as I'm sure there's a much more optimal way of coding.
Thank you!