I want save all information of the dimensions of all jpg's in a directory (including sub-directories).
This seem to work: FOR /R %f IN (*.jpg) DO identify "%f" -size 1920x1080
using standard output like this:
FOR /R %f IN (*.jpg) DO identify "%f" -size 1920x1080 > \dimensions.txt
creates the file dimensions.txt each time as a new file.
and this creates a text file for each jpg, but the files are all across the sub-directories:
FOR /R %f IN (*.jpg) DO identify "%f" -size 1920x1080 > %f.txt
Is there a parameter for sub-directories for identify?
Or any other suggestions?
Saving all dimension information to a file
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Saving all dimension information to a file
You will have to traverse your directory structure in your looping mechanism
- GeeMack
- Posts: 718
- Joined: 2015-12-01T22:09:46-07:00
- Authentication code: 1151
- Location: Central Illinois, USA
Re: Saving all dimension information to a file
On Windows 7 64, and using IM7, this will make a single file containing all the file names and dimensions for all the JPGs in the directory "C:\your_directory\" and all its subdirectories.Loikkanen wrote:I want save all information of the dimensions of all jpg's in a directory (including sub-directories).
This seem to work: FOR /R %f IN (*.jpg) DO identify "%f" -size 1920x1080
using standard output like this:
FOR /R %f IN (*.jpg) DO identify "%f" -size 1920x1080 > \dimensions.txt
creates the file dimensions.txt each time as a new file.
Code: Select all
for /R C:\your_directory\ %I in ( *.jpg ) do identify -format "%f %wx%h\n" "%I" >> \dimensions.txt
If you want the image file names in your output to include the full path, use "%i" instead of "%f" in your "identify" format string.
The drive and path you're searching needs to be in your "for" command right after the "/R" flag.
The output file, "dimensions.txt", will be created (or appended) in the root of the drive you run the command from, like "C:\dimensions.txt". You can, of course, specify any other location and file name.
You need to use the double redirect ">>" in order to append each new line of information to the file. Using just one ">" like you had in your command will overwrite the file each time the loop runs and leave only the last line of data in the file.
Make sure you clear that data file or delete it before you run the command again if you don't want to continue adding to it.
If you put the commands in a batch file, use two percent signs "%%" everywhere you use one "%" on the command line.
Re: Saving all dimension information to a file
Thank you. That worked.
It seems that you can omit the directory, so you can copy the cmd to another directory and use it as it is.
It seems that you can omit the directory, so you can copy the cmd to another directory and use it as it is.
Code: Select all
for /R %%I in ( *.jpg ) do identify -format "%%i %%wx%%h\n" "%%I" >> \dimensions.txt