detect if "already exists" are true copies and delete or rename source file ?

Started by maxandersen, October 30, 2016, 12:23:48 PM

Previous topic - Next topic

maxandersen

Hi,

I'm loving exiftool helping me to clean up my way too many photos into year/month/day folders.

Current command i'm going around running in my various folders are:

sudo exiftool -v -r -d '/volume1/photo/sorted/big_camera/%Y/%m-%b/%d'  "-directory<CreateDate" "-directory<DateTimeOriginal" "-directory<FileModifyDate" .

I got a challenge though - over the years I ended up with copies of same photo and thus I got a lot of
"x already exists - y" errors.

Is there a flag or some awesome trick to have exiftool check if the file are an actual identical file and then rename or even remove the source file ?

Trying to not have to run additional scripts to verify the files are true duplicates.

Any tips appreciated!
/max

Phil Harvey

Hi Max.

ExifTool deals with one file at a time, so you need to find some other way to compare two files to see if they are the same.

You can also move the duplicates by doing this:

exiftool -v -r -d '/volume1/photo/sorted/big_camera/%Y/%m-%b/%d/%%f%%-c.%%e'  "-filename<CreateDate" "-filename<DateTimeOriginal" "-filename<FileModifyDate" .

This will add a "-1", "-2" etc to the names of duplicate files.

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

maxandersen

I tried playing with -c but no luck.

With your command it seem to created nested folders...

Setting new values from IMG_9050.JPG
'IMG_9050.JPG' --> '/Volumes/photo/sorted/lisbeth_phone/2016/03-Mar/29/IMG_9050.JPG/IMG_9050.JPG'
Error creating directory /Volumes/photo/sorted/lisbeth_phone/2016/03-Mar/29/IMG_9050.JPG
Warning = Error creating directory for '/Volumes/photo/sorted/lisbeth_phone/2016/03-Mar[snip]
Warning: Error creating directory for '/Volumes/photo/sorted/lisbeth_phone/2016/03-Mar/29/IMG_9050.JPG/IMG_9050.JPG' - IMG_9050.JPG

any idea what might be wrong ?

Hayo Baan

I think Phil made a typo. Try it with %%-c replaced with -%%c.
Also make sure the directory base /Volumes/photo... is correct and is writeable by you.
Hayo Baan – Photography
Web: www.hayobaan.nl

Phil Harvey

Quote from: Hayo Baan on November 08, 2016, 06:32:34 AM
I think Phil made a typo. Try it with %%-c replaced with -%%c.

No typo this time:

            For %c, these modifiers have a different effects.  If a field
            width is given, the copy number is padded with zeros to the
            specified width.  A leading '-' adds a dash before the copy
            number
, and a '+' adds an underline.  By default, the copy number
            is omitted from the first file of a given name, but this can be
            changed by adding a decimal point to the modifier.  For example:

                -w A%-cZ.txt      # AZ.txt, A-1Z.txt, A-2Z.txt ...


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

Hayo Baan

Thanks Phil for enlightening me, there are just so many features. Always good to learn even more ;D

So that was definitely not it then, so perhaps still something with the paths and/or permissions.
Hayo Baan – Photography
Web: www.hayobaan.nl

BangkokPhoto

I had a similar problem. DoubleKiller from bigbangenterprises worked well.

http://www.bigbangenterprises.de/en/doublekiller/

wywh

Quote from: Phil Harvey on November 08, 2016, 07:08:58 AM
By default, the copy number is omitted from the first file of a given name, but this can be changed by adding a decimal point to the modifier.

I am glad I stumbled on this old message because I prefer to rename also the first duplicate so it is easier to spot.

So the decimal point is added like %%+.c just before c, right?

exiftool '-FileName<DateTimeOriginal' -d '%Y-%m%d-%H%M-%S%%+.c.%%e' .

It seems to work (I have used this pattern for all dates from the beginning because filenames with no spaces are easier in the Terminal):

2000-0101-1200-00_0.jpg
2000-0101-1200-00_1.jpg
2000-0101-1200-00_2.jpg
2000-0101-1200-00_3.jpg


How can I set a fixed amount of copy numbers? For example:

2000-0101-1200-00_9.jpg
2000-0101-1200-00_10.jpg

to:

2000-0101-1200-00_09.jpg
2000-0101-1200-00_10.jpg


- Matti

StarGeek

See the Advanced features section of the -w (-TextOut) option.  Multiple examples under that section.
    For %c, these modifiers have a different effects. If a field width is given, the copy number is padded with zeros to the specified width.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

wywh

Quote from: StarGeek on February 13, 2022, 10:49:36 AM
See the Advanced features section of the -w (-TextOut) option.  Multiple examples under that section.

Thanks.

exiftool '-FileName<DateTimeOriginal' -d '%Y-%m%d-%H%M-%S%%+.2c.%%e' .

2000-0101-1200-00_00.jpg
2000-0101-1200-00_01.jpg
2000-0101-1200-00_02.jpg
2000-0101-1200-00_03.jpg


- Matti

wywh

An additional question. How should I modify:

exiftool '-FileName<DateTimeOriginal' -d '%Y-%m%d-%H%M-%S%%+.2nc.%%e' .

2000-0101-1100-00_01.jpg
2000-0101-1200-00_01.jpg
2000-0101-1200-00_02.jpg
2000-0101-1200-00_03.jpg
2000-0101-1200-00_04.jpg
2000-0101-1300-00_01.jpg


...to number only the duplicates so they are easier to spot in lists:

2000-0101-1100-00.jpg
2000-0101-1200-00_01.jpg
2000-0101-1200-00_02.jpg
2000-0101-1200-00_03.jpg
2000-0101-1200-00_04.jpg
2000-0101-1300-00.jpg


- Matti

Phil Harvey

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

wywh

Quote from: Phil Harvey on February 23, 2022, 08:31:20 AM
Change %+.2nc to %+2c

Thanks, but I already tried it (among other variations), but it does not rename the very first duplicate (in this example to 2000-0101-1200-00_01.jpg):

exiftool '-FileName<DateTimeOriginal' -d '%Y-%m%d-%H%M-%S%%+2c.%%e' .

2000-0101-1100-00.jpg
2000-0101-1200-00_02.jpg
2000-0101-1200-00_03.jpg
2000-0101-1200-00_04.jpg
2000-0101-1200-00.jpg
2000-0101-1300-00.jpg


- Matti

Phil Harvey

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

wywh

Quote from: Phil Harvey on February 23, 2022, 08:57:57 AM
Oh, I see.  Can't be done.

Bummer. Somehow the latest GraphicConverter can rename via EXIF date like that and I wanted to do the same via exiftool.

But this not a big deal because this is only used when going through hundreds of raw images and some of them taken at the same second. Usually I pick just one of those and trash the rest and do the rename again. Another option would be to rename in subsecond precision in the first run.

- Matti