Wednesday, March 15, 2017

Using imagemagick to identify all files in multiple subfolders


I want to run ImageMagick with the identify option to scan all images in multiple folders at one time.


It should be run similar to the below syntax but I want to log it all to the same one log file, and I'd like to make a batch file for this if possible too.


magick identify -verbose "D:\Images" >log.txt 2>&1

Answer



You could just run a FOR /F loop with a DIR command to get the full explicit path to each file from the source directory (D:\Images) and traverse it recursively.


This essentially passes each full explicit path and file name to the magick command one-by-one and then you will append these to the log file for later review.


Additional resources and an example command with applicable syntax using all this is provided for you below to utilize accordingly. This should be a good starting point for you.




Command Line Example


NOTE: You can replace the portion of
D\Images\*.*" as D\Images\*.jpg" or whatever file extensions to
only list those particular file extensions and you could also change
it to F:\OtherFolder\*.png" or whatever for the need so a different
folder path and/or file extensions can be specified in that portion of
the example I provided below.


FOR /F "DELIMS=" %A IN ('DIR /A-D /S /B "D:\Images\*.*"') DO magick identify -verbose "%~A">>D:\logfile.txt



Batch Script Example


NOTE: I made this script so you can set the variables for your needs up top easily to accommodate accordingly per run.


@ECHO ON
SET Source=D:\Images
SET Ext=*.jpg
SET LogFile=D:\logfile.txt
FOR /F "DELIMS=" %%A IN ('DIR /A-D /S /B "%Source%\%Ext%"') DO magick identify -verbose "%%~A">>"%LogFile%"
GOTO EOF



Further Resources


No comments:

Post a Comment

hard drive - Leaving bad sectors in unformatted partition?

Laptop was acting really weird, and copy and seek times were really slow, so I decided to scan the hard drive surface. I have a couple hundr...