Adding YYYYMM to folder

Started by boredcollie, February 21, 2021, 07:17:50 PM

Previous topic - Next topic

boredcollie

Hi
I'm currently using the following command to sort my pictures:


exiftool -P -d '%Y%m%d_%H%M%S' \
   '-filename<${FileModifyDate;s/(^\d{4}).*/$1/}/${FileModifyDate}_${ImageSize}%+.3c.%le' \
   '-filename<${CreateDate;s/(^\d{4}).*/$1/}/${CreateDate}_${ImageSize}%+.3c.%le' \
   '-filename<${DateTimeOriginal;s/(^\d{4}).*/$1/}/${Model}/${DateTimeOriginal}_${ImageSize}%+.3c.%le' \
   '-filename<${DateTimeOriginal;s/(^\d{4}).*/$1/}/${Model}/${DateTimeOriginal}_${ImageSize}_${Model}%+.3c.%le' \
   -r .


this organise the pictures in a tree like:


2020
- NIKOND80
- iPhone 3GS
   - 20130519_164422_2048x1536_iPhone 3GS_000.jpg
- iPhone 4 ...


I'd like to add a date before the subfolder like

20130519 - iPhone 3GS

Reading this forum I did some test, trial and error and added -> #;DateFmt('%Y%m%d') like in this example, but without the expected result.


exiftool -P -d '%Y%m%d_%H%M%S' \
   '-filename<${FileModifyDate;s/(^\d{4}).*/$1/}/${FileModifyDate}_${ImageSize}%+.3c.%le' \
   '-filename<${CreateDate;s/(^\d{4}).*/$1/}/${CreateDate}_${ImageSize}%+.3c.%le' \
   '-filename<${DateTimeOriginal;s/(^\d{4}).*/$1/}/${Model}/${DateTimeOriginal#;DateFmt('%Y%m%d')}_${ImageSize}%+.3c.%le' \
   '-filename<${DateTimeOriginal;s/(^\d{4}).*/$1/}/${Model}/${DateTimeOriginal#;DateFmt('%Y%m%d')}_${ImageSize}_${Model}%+.3c.%le' \
   -r .


I'd like also to add in the same command this one that I use for Fuji X100f that use RawImageFullSize instead of ImageSize.

exiftool -P -d %Y%m%d_%H%M%S '-filename<${DateTimeOriginal}_${RawImageFullSize}_${Model}%+.3c.%le' -r .

Is there a way to have all of this in just 1 command?

Thanks for any help!


StarGeek

Since you're using single quotes to surround each tag copy, you need to use double quotes when quoting something inside the single quotes.  So the DateTimeOriginal part would be {DateTimeOriginal#;DateFmt("%Y%m%d")

For the part with RawImageFullSize, just repeat what you did for ImageSize but place it after the the image size lines.  When you assign a tag, subsequent assignments will override earlier assignments as long as the tag used exists.  As a simplified example
'-filename<${ImageSize}%+.3c.%le' '-filename<${RawImageFullSize}%+.3c.%le'
Since the RawImageFullSize part comes after the ImageSize part, it will have priority.  If RawImageFullSize doesn't exist, then the command falls back to using ImageSize.

* 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).

boredcollie

Thanks!

It works. I'm wondering if there is a way to replace space in the filename for the model name. E.g

From this:
20200308_121324_4160x3120_COOLPIX W100_000.jpg

To:
20200308_121324_4160x3120_COOLPIX_W100_000.jpg

Just for future references and to help other folks:


exiftool -P -d '%Y%m%d_%H%M%S' \
   '-filename<${FileModifyDate#;DateFmt("%Y")}/${FileModifyDate#;DateFmt("%Y%m%d")}/${FileModifyDate}_${ImageSize}%+.3c.%le' \
   '-filename<${CreateDate#;DateFmt("%Y")}/${CreateDate#;DateFmt("%Y%m%d")}/${CreateDate}_${ImageSize}%+.3c.%le' \
   '-filename<${DateTimeOriginal#;DateFmt("%Y")}/${DateTimeOriginal#;DateFmt("%Y%m%d")} - ${Model}/${DateTimeOriginal}_${ImageSize}%+.3c.%le' \
   '-filename<${DateTimeOriginal#;DateFmt("%Y")}/${DateTimeOriginal#;DateFmt("%Y%m%d")} - ${Model}/${DateTimeOriginal}_${ImageSize}_${Model}%+.3c.%le' \
   '-filename<${DateTimeOriginal#;DateFmt("%Y")}/${DateTimeOriginal#;DateFmt("%Y%m%d")} - ${Model}/${DateTimeOriginal}_${RawImageFullSize}_${Model}%+.3c.%le' \
   -r .


This command organise the pictures in a folder structure like in this example


~/pictures/test/ ls -1
2016
2017
2018
2019
2020

~/pictures/test/ ls -1 2020
20200308 - COOLPIX W100
20201024 - COOLPIX W100
20201025 - COOLPIX W100
20201026 - COOLPIX W100
20201028 - COOLPIX W100
COOLPIX W100

~/pictures/test/2020/ ls -1 20200308\ -\ COOLPIX\ W100
20200308_121324_4160x3120_COOLPIX W100_000.jpg




Phil Harvey

Quote from: boredcollie on February 22, 2021, 05:44:03 AM
It works. I'm wondering if there is a way to replace space in the filename for the model name. E.g

From this:
20200308_121324_4160x3120_COOLPIX W100_000.jpg

To:
20200308_121324_4160x3120_COOLPIX_W100_000.jpg

for this you can use ${model;tr/ /_/}

- 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 ($).