ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: remco on February 18, 2023, 02:56:42 PM

Title: Copy instead of Move, but only if the file does not exists
Post by: remco on February 18, 2023, 02:56:42 PM
I have a few photo/video sources which need to stay as they are and will be updated when new photos are made. I want to copy these to my library, but only if the file does not exist on the destination location. Is such possible?
Title: Re: Copy instead of Move, but only if the file does not exists
Post by: StarGeek on February 18, 2023, 04:45:24 PM
Yes.  See the second paragraph under Notes on the Writing "FileName" and "Directory" tags page (https://exiftool.org/filename.html), which points to Example #5 (https://exiftool.org/filename.html#ex5).  See also the -o (-out) option (https://exiftool.org/exiftool_pod.html#o-OUTFILE-or-FMT--out).

Exiftool won't overwrite existing files, it will just give an error.

Example: I have a directory with two files, Test3.jpg and Test4.jpg.  First, I try to create a copy of test4.jpg with the same name as Test3.jpg, but this gives an error.  Then I create a copy called Test5.jpg and that succeeds.
C:\Programs\My_Stuff>exiftool -G1 -a -s -filepath Y:\!temp\aaaa
======== Y:/!temp/aaaa/Test3.jpg
[System]        FilePath                        : Y:/!temp/aaaa/Test3.jpg
======== Y:/!temp/aaaa/test4.jpg
[System]        FilePath                        : Y:/!temp/aaaa/test4.jpg
    1 directories scanned
    2 image files read

C:\Programs\My_Stuff>exiftool -o . -Filename=y:\!temp\aaaa\Test3.jpg Y:\!temp\aaaa\Test4.jpg
Error: 'y:/!temp/aaaa/Test3.jpg' already exists - Y:/!temp/aaaa/Test4.jpg
    0 image files updated
    1 files weren't updated due to errors

C:\Programs\My_Stuff>exiftool -o . -Filename=y:\!temp\aaaa\Test5.jpg Y:\!temp\aaaa\Test4.jpg
    1 image files copied

C:\>exiftool -G1 -a -s -filepath Y:\!temp\aaaa
======== Y:/!temp/aaaa/Test5.jpg
[System]        FilePath                        : Y:/!temp/aaaa/Test5.jpg
======== Y:/!temp/aaaa/Test3.jpg
[System]        FilePath                        : Y:/!temp/aaaa/Test3.jpg
======== Y:/!temp/aaaa/Test4.jpg
[System]        FilePath                        : Y:/!temp/aaaa/Test4.jpg
    1 directories scanned
    3 image files read