Hello to all,
I am writing a script in bash shell linux to change the name of the imported pictures to include the shutter actuations among the model name of the camera and tha CreateDate.
Is there a way to do that in a single line or otherwise?
Yes. Something like this:
exiftool "-testname<${createdate}_${model;}_${shuttercount}.%e" -d "%Y-%m-%d_%H%M%S" DIR
The semicolon after "model" uses the advanced formatting feature to delete invalid characters from the model name.
See the Date format codes section of the file-renaming page (https://exiftool.org/filename.html#codes) for more details about the date/time formatting string.
Once you are convinced the file names are what you want, change "testname" to "filename" to actually rename the files.
- Phil
Thank you very much!
In the mean time I wrote the script that included the $filenumber
instead of ${shuttercount}
as you mentioned.
Here it is altogether:
#!/bin/bash
FILE=""
DIR="$1"
if [ -d "$DIR" ]
then
if [ "$(ls -A $DIR)" ]
then
exiftool '-Directory<DateTimeOriginal' -d %m%Y .
exiftool '-filename<${model;}_${createdate#;DateFmt("%d-%b-%y_%H%M%S")}_$filenumber.%e' . -r
# exiftool '-filename<${model;}_${createdate#;DateFmt("%d-%b-%y_%H%M%S")}_${shuttercount}.%e' . -r
else
echo "$DIR is Empty"
fi
else
echo "Directory $DIR not found."
fi
I included here the line you mentioned REMed replacing $filenumber with ${shuttercount} (have not tested it I thing it will work if unREMed)
Sorry forgot to change the "." in the exiftool commands with the $DIR variable in the script so keep that in mind
Sorry one more, the script included here is the correct one.
#!/bin/bash
FILE=""
DIR="$1"
#DIR="."
if [ -d "$DIR" ]
then
if [ "$(ls -A $DIR)" ]
then
cd $DIR
exiftool '-Directory<DateTimeOriginal' -d %m%Y .
#exiftool '-filename<${model;}_${createdate#;DateFmt("%d-%b-%y_%H%M%S")}_$filenumber.%e' . -r
exiftool '-filename<${model;}_${createdate#;DateFmt("%d-%b-%y_%H%M%S")}_${shuttercount}.%e' . -r
else
echo "$DIR is Empty"
fi
else
echo "Directory $DIR not found."
fi
Processed two kind of pictures with the ${shuttercount} attribute one of those failed with the following message:
Warning: [minor] Tag 'shuttercount' not defined - ./082022/BC1X1105.CR2
Warning: No writable tags set from ./082022/BC1X1105.CR2
So it does not always work. The $filenumber does the work just fine! Note that if you leave out the $filenumber will not process all photos taken in the same second in time.
You can move and rename the file in one command:
exiftool '-filename<${datetimeoriginal}/${model;}_${createdate#;DateFmt("%d-%b-%y_%H%M%S")}_${shuttercount}.%e' -d %m%Y . -r
- Phil