ExifTool Forum

ExifTool => Bug Reports / Feature Requests => Topic started by: jotzet79 on August 13, 2023, 04:44:59 AM

Title: Introduce meta tag for Backup File
Post by: jotzet79 on August 13, 2023, 04:44:59 AM
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
Title: Re: Introduce meta tag for Backup File
Post by: StarGeek on August 13, 2023, 12:29:26 PM
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 (https://exiftool.org/exiftool_pod.html#efile-NUM-ERRFILE).

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 (https://exiftool.org/exiftool_pod.html#ARGFILE) to process the missing files.
Title: Re: Introduce meta tag for Backup File
Post by: jotzet79 on August 13, 2023, 02:45:12 PM
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 (https://exiftool.org/exiftool_pod.html#efile-NUM-ERRFILE).

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 (https://exiftool.org/exiftool_pod.html#ARGFILE) 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
Title: Re: Introduce meta tag for Backup File
Post by: StarGeek on August 13, 2023, 05:51:11 PM
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
Title: Re: Introduce meta tag for Backup File
Post by: Phil Harvey on August 21, 2023, 08:36:53 AM
Very smart StarGeek.  I think this solution should do just what Joachim wants.

- Phil