Introduce meta tag for Backup File

Started by jotzet79, August 13, 2023, 04:44:59 AM

Previous topic - Next topic

jotzet79

In my current usecase I would like to check if a backupfile exists: based on this information I would skip editing metadata, otherwise I would process the file.

I would like to check on the -BackupFile (File path) in the -if tag.

Background is that the environment where I am using exiftool is prone to interrupts, and when I start over already processed files get updated again...

Thank you,
Joachim

StarGeek

Here's a two step procedure to get a list of files not in the backup folder. 
C:\>exiftool -G1 -a -s -filename Y:\!temp\BackupPath
======== Y:/!temp/BackupPath/Test3.jpg
[System]        FileName                        : Test3.jpg
======== Y:/!temp/BackupPath/Test4.jpg
[System]        FileName                        : Test4.jpg
    1 directories scanned
    2 image files read

C:\>exiftool -efile y:\!temp\temp_Error.txt -if "$filename" -srcfile %dBackupPath/%F -filename y:\!temp\Test3.jpg y:\!temp\Test4.jpg y:\!temp\Test5.jpg
======== y:/!temp/BackupPath/Test3.jpg
File Name                      : Test3.jpg
======== y:/!temp/BackupPath/Test4.jpg
File Name                      : Test4.jpg
Error: File not found - y:/!temp/BackupPath/Test5.jpg
    2 image files read
    1 files could not be read

C:\>type y:\!temp\temp_Error.txt
y:/!temp/BackupPath/Test5.jpg

First command shows that there are only two files in /BackupPath/, Test3.jpg and Test4.jpg.  The next command attempts to list the filenames for files Test3.jpg, Test4.jpg, and Test5.jpg.  Because Test5.jpg doesn't exist, it gets saved to the filename used by the -efile option.

temp_Error.txt now contains a list of files missing from /BackupPath/.  You'll have to do a search/replace to correct the file paths in a text editor, but once that is done, you can use the -@ (Argfile) option to process the missing files.
"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

jotzet79

Quote from: StarGeek on August 13, 2023, 12:29:26 PMHere's a two step procedure to get a list of files not in the backup folder. 
C:\>exiftool -G1 -a -s -filename Y:\!temp\BackupPath
======== Y:/!temp/BackupPath/Test3.jpg
[System]        FileName                        : Test3.jpg
======== Y:/!temp/BackupPath/Test4.jpg
[System]        FileName                        : Test4.jpg
    1 directories scanned
    2 image files read

C:\>exiftool -efile y:\!temp\temp_Error.txt -if "$filename" -srcfile %dBackupPath/%F -filename y:\!temp\Test3.jpg y:\!temp\Test4.jpg y:\!temp\Test5.jpg
======== y:/!temp/BackupPath/Test3.jpg
File Name                      : Test3.jpg
======== y:/!temp/BackupPath/Test4.jpg
File Name                      : Test4.jpg
Error: File not found - y:/!temp/BackupPath/Test5.jpg
    2 image files read
    1 files could not be read

C:\>type y:\!temp\temp_Error.txt
y:/!temp/BackupPath/Test5.jpg

First command shows that there are only two files in /BackupPath/, Test3.jpg and Test4.jpg.  The next command attempts to list the filenames for files Test3.jpg, Test4.jpg, and Test5.jpg.  Because Test5.jpg doesn't exist, it gets saved to the filename used by the -efile option.

temp_Error.txt now contains a list of files missing from /BackupPath/.  You'll have to do a search/replace to correct the file paths in a text editor, but once that is done, you can use the -@ (Argfile) option to process the missing files.

Hmm, nice way to tackle complex situations where file from various (interdependent) sources need to be processed.

However what I actually meant, was exiftool's own backups ie "_original" files.

And yes of course I could also use 2 different commands to come to the result I have in mind. On the other hand I find it much nicer if there are built in ways.

Thanks for your thoughts...
Joachim

StarGeek

Phil will have to answer about building it in, but in the mean time here's a quick config file.

Example output, Test3.jpg has a backup, Test4.jpg does not
C:\>exiftool -G1 -a -s -filename y:\!temp\Test3.jpg* y:\!temp\Test4.jpg*
======== y:/!temp/Test3.jpg
[System]        FileName                        : Test3.jpg
======== y:/!temp/Test3.jpg_original
[System]        FileName                        : Test3.jpg_original
======== y:/!temp/Test4.jpg
[System]        FileName                        : Test4.jpg
    3 image files read

C:\>exiftool -config CheckForOriginal.config -G1 -a -s -BackupFile y:\!temp\Test3.jpg y:\!temp\Test4.jpg
======== y:/!temp/Test3.jpg
[Composite]     BackupFile                      : True
======== y:/!temp/Test4.jpg
[Composite]     BackupFile                      : False
    2 image files read
"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

Phil Harvey

Very smart StarGeek.  I think this solution should do just what Joachim wants.

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