How to specify sequential file name list?

Started by AlisonP, October 23, 2018, 07:58:44 PM

Previous topic - Next topic

AlisonP

I am a newbie to EXIFTool.  Thanks to Phil for not only an amazing tool but setting up this forum for questions! 

I have a new LAOWA  25MM 2.5-5x macro lens.   Importing my photographs into Lightoom, there is no lens ID (because Adobe does not have a profile for it) and no F-stop (because there is no electronic communication between the lens and the camera).  I have figured out what commands to use to add the lens ID and the F-stop, and also to put the magnification into the User Comment field.  My question is how to specify a sequential list of files for the commands to operate on.  From the camera, the file names are DSC#####.ARW where the # fields are sequential numbers. 

In one day, I might have dozens of files for focus stacking, and I am testing at different F-stops.  So I have a sequence of files at e.g., F2.8, the next at F4, etc.  This may be a DOS question instead of a question for ExifTool, but how to I specify a sequential set of files for ExifTool operation, so I can change the F-stop on just a subset of my files?

For example, if I have files DSC04835.ARW up through DSC04902.AWR for which I want to change the metadata, is there a way to specify this set in the command line?

There is a workaround of course, but it is tedious -- I could copy the files into separate subdirectories, and then execute the appropriate command on *.* in each subdirectory, but I am looking for an easier way.

Thanks for any suggestions

StarGeek

There might be a better way to do this, but off hand here's what I can come up with.  Give files DSC04835.jpg through DSC04846.jpg and grabbing only files numbered 4838 through 4844:
exiftool -g1 -a -s -filename -if "${filename;s/\D//g}>=4838 and ${filename;s/\D//g}<=4844"

C:\>exiftool -g1 -a -s -filename -if "${filename;s/\D//g}>=4838 and ${filename;s/\D//g}<=4844" Y:\!temp\aa
======== Y:/!temp/aa/DSC04838.jpg
---- System ----
FileName                        : DSC04838.jpg
======== Y:/!temp/aa/DSC04839.jpg
---- System ----
FileName                        : DSC04839.jpg
======== Y:/!temp/aa/DSC04840.jpg
---- System ----
FileName                        : DSC04840.jpg
======== Y:/!temp/aa/DSC04841.jpg
---- System ----
FileName                        : DSC04841.jpg
======== Y:/!temp/aa/DSC04842.jpg
---- System ----
FileName                        : DSC04842.jpg
======== Y:/!temp/aa/DSC04843.jpg
---- System ----
FileName                        : DSC04843.jpg
======== Y:/!temp/aa/DSC04844.jpg
---- System ----
FileName                        : DSC04844.jpg
    1 directories scanned
    5 files failed condition
    7 image files read


This assumes there are no other numbers in the filename.  For example, if you had something like DSC04838 (1).jpg, then the number would end up being 48381.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

Phil Harvey

StarGeek posted while I was composing, but here it is anyway:

ExifTool can do this but it will be slow since it (unfortunately) will have to read all files (maybe I could figure out a way to speed this up some time):

exiftool -if "$filename ge 'DSC04835.ARW' and $filename le 'DSC04902.ARW'" ... -ext arw DIR

There may be a faster way to do this using some shell or bat feature.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

StarGeek

Quote from: Phil Harvey on October 23, 2018, 09:55:05 PM
exiftool -if "$filename ge 'DSC04835.ARW' and $filename le 'DSC04902.ARW'" ... -ext arw DIR

D'oh!

Concentrated so much on figuring out how to exact the numbers that I overlooked the obvious string comparison.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

AlisonP

Thanks so much StarGeek and Phil!  For both the quick response and solution!   :) :) :)

Yes, with the solution that you have provided this can be done with scripted .bat which I think I can now put together.