exiftool serialnumber

Started by j99mac, July 28, 2021, 12:24:48 PM

Previous topic - Next topic

j99mac

I am looking to fine serialnumber in my images.
I want to make a if then to rename image with the camera number verible

I tryed this
SerialNum = $(exiftool -SerialNumber $path")
CameraNum = cam001

if $SerialNum
then $CameraNum

exiftool -d '%Y%m%d' '-FileName <$CameraNum_${CreateDate;}_%.2nc.%e' "$path/" &&

I can get it to add the date but not the verible example cam001_01022020.tif of the file name i am looking to have



StarGeek

You can do all of this in exiftool with a simple user defined tag.  Previous thread on the subject.  This exact operation is something I have set up for images I collect from friends/family, though I use the owner's name instead.

The basic config would be
%Image::ExifTool::UserDefined = (
'Image::ExifTool::Composite' => {
CameraBySerialNumber => {
Require => 'SerialNumber',
ValueConv => q{
if ($val eq '111111') { return "Camera 1"; }
if ($val eq '222222') { return "Camera 2"; }
if ($val eq '333333') { return "Camera 3"; }
return undef;
},
},
},
);
#------------------------------------------------------------------------------
1;  #end


Replace the numbers with the serial number of the camera and replace "Camera #" with the value you want to be returned for that camera.  Save this to a file in the same directory as exiftool.  Then you could run this command (change "CameraBySerialNumber.config" to whatever name you saved the config file as)
exiftool -config CameraBySerialNumber.config -d '%Y%m%d' '-FileName <${CameraBySerialNumber}_${CreateDate;}_%.2nc.%e' /path/to/files/

Currently, any camera that doesn't have a matching serial number is skipped, but you could change that by changing
return undef;
into
return "Default Value";
* 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).

j99mac

Where do I find the Exiftool to save the config file? I tryed it in saved in the dir where I have my main script, but got some errors

StarGeek

I have no idea where you put your copy of exiftool.

I just suggested putting it in the same directory as exiftool for ease of use, as exiftool will check the directory it is located in for config files.  You can instead put the config anywhere you want and use the full path to the file
exiftool -config /path/to/CameraBySerialNumber.config -d '%Y%m%d' '-FileName <${CameraBySerialNumber}_${CreateDate;}_%.2nc.%e' /path/to/files/
* 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).

j99mac

I am looking to change createDate to DateTimeOriginal. When i run the command with with DateTimeOriginal it give a file name that had Feb in it. How to i get it to be yyymmddhm?Date and time all in numbers? Also if i  already have something in the file name how do i get it to keep it to add it to the end

StarGeek

I can't really comment without seeing what you're actually doing.

It works correctly here, using Testname instead of Filename as I don't actually want to rename my test file
C:\>exiftool -g1 -a -s -SerialNumber -DateTimeOriginal y:\!temp\Test4.jpg
---- ExifIFD ----
DateTimeOriginal                : 2021:07:31 13:37:50
SerialNumber                    : 111111

C:\>exiftool -config CameraBySerialNumber.config -d "%Y%m%d" "-Testname<${CameraBySerialNumber}_${DateTimeOriginal;}_%.2nc.%e" y:\!temp\Test4.jpg
'y:/!temp/Test4.jpg' --> 'y:/!temp/Camera 1_20210731_01.jpg'
    0 image files updated
    1 image files unchanged
* 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).

j99mac

When the test command is rin fir date and tone it output this 2021:07:31 13:37:50. How can i get it to output with out : and with one long strong?

StarGeek

I don't understand.  See my last post for the command that works.
* 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).

j99mac


StarGeek

Use the -d (-dateFormat) option like in your first post in this thread.
* 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).