Sorting 200,000+ pictures

Started by R Javier, May 10, 2020, 07:50:11 AM

Previous topic - Next topic

R Javier

Hello, I just recovered images from my hard disk which got accidentally formatted.
The recovered images are having the file name eg: f470941600.jpg
Is there any chance of recovering the old file names

For sorting the images I tried the following copy paste commands from the discussions

exiftool -d %Y_%m_%d '-filename<${filemodifydate}/%f.%e' '-filename<${datetimeoriginal}/${make;}_${model;}_%f.%e'  DIR
Gave a result in which the sorted filenames were
eg :NIKON CORPORATION_NIKON D3200_f470941600.jpg

Executing this command on fresh files
exiftool -r '-FileName<CreateDate' -d '%Y-%m-%d/%H_%M_%S%%-c.%%le'
Gave a result
eg: 16_15_29.jpg.  this appears to be the time created.

Later tried the command
exiftool -a FILE
The file creation date detail is showing in
Date/Time Created              : Date and time
Date/Time Original              : Date and time
Create Date                        : Date and time
Date Created                      : Only date
Date Created                     : Date and time
Noticed there were two places showing date created
Can anyone help me in writing a command which will give the following result
(CAMERA MODEL)_(CREATED DATE)_(CREATED TIME)_(1,2,3.. in case of duplicate files).jpg

Folder arrangement
(YEAR)_(MONTH)

Thank you in advance

Phil Harvey

But what format date/time do you want, and which tag(s) do you want to use for the date/time, and what do you want to do if the model isn't available?

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

R Javier



Hi, I plan to arrange everything in the following manner.
Prefer the folders to be arranged by month in the format
MONTH_YEAR
example: 05_2012
              06_2012
              12_2012
              01_2013

Inside this folder the file to be named as
CAMERA MODEL_TIME_DATE_(1,2,3...duplicates).JPG

example:
For a picture taken on 15 MAY 2012 at 1630 hrs

CANON_EOS_70D_16_30_15_05_2012.JPG

And if there is a duplicate for the same file then
CANON_EOS_70D_16_30_15_05_2012_00001.JPG
CANON_EOS_70D_16_30_15_05_2012_00002.JPG


The tags which I want to use for finding the date/time is preferably : Date/Time Original, Create Date, Date/Time Created
At present I am dealing with only .JPG files
Hopefully the model, date and time details are available in all the files. Else for the cases

When MODEL is available

1)
If DATE is not available,
but MODEL and TIME available
It can be named as
MODEL_TIME.JPG
example : CANON_EOS_70D_16_30.JPG
In case of duplicates : CANON_EOS_70D_16_30_00001.JPG
                                 CANON_EOS_70D_16_30_00002.JPG

And put into a separate folder named : 2020_No date info

2)
If TIME and DATE not available,
only MODEL available
It can be named as
MODEL.JPG
In case of duplicates : CANON_EOS_70D_00001.JPG
                                 CANON_EOS_70D_00002.JPG

And put into a separate folder named : 2020_No time date info

3)
If TIME is not available,
but MODEL and DATE available
It can be named as
MODEL_DATE.JPG
example : CANON_EOS_70D_15_05_2012.JPG
In case of duplicates : CANON_EOS_70D_15_05_2012_00001.JPG
                                 CANON_EOS_70D_15_05_2012_00002.JPG

These can be put into the same folder format as mentioned above i.e : 05_2012

When MODEL is not available

4)
If MODEL is not available,
but TIME and DATE is available
It can be named as
IMG_TIME_DATE.JPG
example : IMG_16_30_15_05_2012.JPG
In case of duplicates : IMG_16_30_15_05_2012_00001.JPG
                                 IMG_16_30_15_05_2012_00002.JPG

These can be put into the same folder format as mentioned above i.e : 05_2012

5)
If MODEL and TIME is not available,
only DATE is available
It can be named as
IMG_DATE.JPG
example : IMG_15_05_2012.JPG
In case of duplicates : IMG_15_05_2012_00001.JPG
                                 IMG_15_05_2012_00002.JPG

These can be put into the same folder format as mentioned above i.e : 05_2012

6)
If MODEL and DATE is not available,
only TIME available
It can be named as
IMG_TIME.JPG
example : IMG_16_30.JPG
In case of duplicates : IMG_16_30_00001.JPG
                                 IMG_16_30_00002.JPG

And put into a separate folder named : 2020_No model date info

7)
If MODEL, TIME and DATE is not available
It can be named as just
IMG.JPG
In case of duplicates : IMG_00001.JPG
                                 IMG_00002.JPG

And put into a separate folder named : 2020_No model time date info


This is the main plan but anything close will also work.
Suggest changes or recommend a better sorting method.
Kindly guide

Thank you very much

Phil Harvey

Wow, OK.  That took me quite a while to sort through these possibilities.

Try this command:

exiftool -@ my.args DIR

with the following my.args file:

-d
%H_%M_%d_%m_%Y
-testname=2020_No time date info/IMG%+5nc.%e
-testname<2020_No date info/IMG_${timecreated;s/:\d+$//;tr/:/_}%+5nc.%e
-testname<${datecreated#;s/(\d+):(\d+):(\d+)/${2}_$1}/IMG_${datecreated;s/(\d+):(\d+):(\d+)/${3}_${2}_$1}%+5nc.%e
-testname<${createdate#;DateFmt('%m_%Y')}/IMG_${createdate}%+5nc.%e
-testname<${datetimeoriginal#;DateFmt('%m_%Y')}/IMG_${datetimeoriginal}%+5nc.%e
-testname<2020_No time date info/${model;tr(a-z /)(A-Z_)d}%+5nc.%e
-testname<2020_No date info/${model;tr(a-z /)(A-Z_)d}_${timecreated;s/:\d+$//;tr/:/_}%+5nc.%e
-testname<${datecreated#;s/(\d+):(\d+):(\d+)/${2}_$1}/${model;tr(a-z /)(A-Z_)d}_${datecreated;s/(\d+):(\d+):(\d+)/${3}_${2}_$1}%+5nc.%e
-testname<${createdate#;DateFmt('%m_%Y')}/${model;tr(a-z /)(A-Z_)d}_${createdate}%+5nc.%e
-testname<${datetimeoriginal#;DateFmt('%m_%Y')}/${model;tr(a-z /)(A-Z_)d}_${datetimeoriginal}%+5nc.%e


If this does what you want, then change all "testname" in my.args to "filename" to actually do the renaming.

Note that the first duplicate file will not have a number, and the second duplicate with have _00002 added to the name.  Adding _00001 to the first duplicate would be very difficult.

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

R Javier

Thank you very much Phil

The command executed beautifully.
All the images are now sorted and organised.

R Javier

Hello Phil,

Now that I have got the image files organised, I am moving over to the recovered music files.
Can a similar command be written for sorting music files.

I plan to have the files arranged into the following folder pattern provided all the tags are available

      |_ ARTIST (folder)
               |_ ALBUM (sub folder)
                        |_ ARTIST - TITLE.mp3 (actual music file)
       
The tags which I like to use are
for folder name artist :  ARTIST
for subfolder name album : ALBUM
for the actual music file naming tags artist and title : ARTIST - TITLE

In case if any details is missing

1)
If ALBUM is missing,
only ARTIST and TITLE is available

File folder arrangement
                     |_ ARTIST (folder)
                             (No sub folder)
                                       |_ ARTIST - TITLE.mp3 (actual music file)

2)
If TITLE is missing,
only ARTIST and ALBUM is available
(Use the tag TRACK for file naming. If tag TRACK is also missing then simply name as Track i.e ARTIST - Track0000.mp3)

File folder arrangement
                    |_ ARTIST (folder)
                             |_ ALBUM (sub folder)
                                       |_ ARTIST - TRACK0000.mp3, ARTIST - TRACK0001.mp3 (actual music file)

3)
If ALBUM and TITLE is missing,
only ARTIST is available,
(Use the tag TRACK for file naming. If tag TRACK is also missing then simply name as Track i.e ARTIST - Track0000.mp3)

File folder arrangement
                    |_ ARTIST (folder)
                            (No sub folder)
                                      |_ ARTIST - TRACK0000.mp3, ARTIST - TRACK0001.mp3  (actual music file)

4)
If ARTIST is missing,
only ALBUM and TITLE is available

Then move the file to the folder named MISC
File folder arrangement
                    |_MISC (folder)
                              |_ ALBUM (sub folder)
                                       |_ TITLE.mp3 (actual music file)

5)
If ARTIST and TITLE is missing
only ALBUM is available,
(Use the tag TRACK for file naming. If tag TRACK is also missing then simply name as Track i.e Track0000.mp3)

Then move the file to the folder named MISC
File folder arrangement
                    |_MISC (folder)
                             |_ ALBUM (sub folder)
                                      |_ TRACK0000.mp3, TRACK0001.mp3  (actual music file)

6)
If ALBUM and ARTIST is missing
only TITLE is available,

Then move the file to the folder named MISC
File folder arrangement
                    |_MISC (folder)
                             (No sub folder)
                                      |_ TITLE.mp3 (actual music file)

7)
If ARTIST, ALBUM and TITLE is missing,
(Use the tag TRACK for file naming. If tag TRACK is also missing then simply name as Track i.e Track0000.mp3)

Then move the file to the folder named MISC
File folder arrangement
                    |_MISC (folder)
                             (No sub folder)
                                       |_ TRACK0000.mp3, TRACK0001.mp3 (actual music file)

This is the main plan.
Please suggest changes or recommend a better sorting method.

Thank you very much

Phil Harvey

Wow.  OK.  I really don't have time to do this again for you.  That last one took me a long time and I have a lot of other people to help out here.  I hope you can figure this out yourself.

- 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

You might look into a dedicated music tagging program such as MP3tag.  It can do renaming/sorting as well as fill in missing tags.
* 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).