ExifTool Forum

ExifTool => Newbies => Topic started by: JonAgain on January 19, 2022, 07:26:09 PM

Title: Using a csv as a source file
Post by: JonAgain on January 19, 2022, 07:26:09 PM
Hello everyone, I'm back with another newbie question.  I have been purging ancestor data from an ungodly amount graphic files and need a little help with speeding up the process. 

My process is: use exiftool to search directories and identify file with ancestor metadata and export the findings to a csv.  That tells me how many files are affected and also gives me a log of what files are going to be updated incase I need to restore them from a backup for what ever reason. 

exiftool -p -r -if '$documentancestors and (()=$documentancestors =~ /, /g) > 100' '/path/to/files'/ > /path/to/output/file.csv

After identifying the files I use the tool to then remove the ancestor data.

exiftool -m -overwrite_original_in_place -r -if '$documentancestors and (()=$documentancestors =~ /, /g) > 100' -documentancestors= /path/to/files/

This works fine for small directories.  But if its a large directory with 5000 subfolders, 30000 files total, and 2000 identified files that need to be updated, there is a lot of unnecessary rescanning going on.  I have not been able to just scan, clean, and export results to a csv.  The csv will always just be empty. 

What I am looking to do:  Scan, clean, and export a csv in one swoop.  Or use the csv file I generate during the discovery as a source file for what needs to be updated.

Any help would be much appreciated.



Title: Re: Using a csv as a source file
Post by: StarGeek on January 19, 2022, 08:36:16 PM
Copy and edit your csv so that it only consists of the files you want to process and the tags you want to clear.  Fill those tag columns with a -.  Then run this:
exiftool -f -csv=/path/to/file.csv /path/to/files

C:\>exiftool -G1 -a -s -Description y:\!temp\Test4.jpg
[XMP-dc]        Description                     : New Description

C:\>type temp.csv
SourceFile,Description
y:/!temp/Test4.jpg,-
C:\>exiftool -P -overwrite_original -f -csv=temp.csv y:\!temp\Test4.jpg
    1 image files updated

C:\>exiftool -G1 -a -s -Description y:\!temp\Test4.jpg

C:\>
Title: Re: Using a csv as a source file
Post by: JonAgain on January 20, 2022, 12:13:21 PM
I am not sure if this would work for ancestor metadata.  There can over a thousand lines of excessive ancestor metadata that just needs to be removed and every line of metadata has a unique string of characters. 

Maybe just exporting to a csv after the file has been updated will suffice.  Any help with just making the results exported to a csv would be great.
Title: Re: Using a csv as a source file
Post by: StarGeek on January 20, 2022, 12:43:53 PM
It doesn't matter how many lines, just as long as you get the tag name right.
Title: Re: Using a csv as a source file
Post by: JonAgain on January 20, 2022, 01:02:20 PM
So how would I go about identifying the tag with this stuff? 

<photoshop:DocumentAncestors>
            <rdf:Bag>
               <rdf:li>0005AD47B2A0C30E8C4287762997BFF5</rdf:li>
               <rdf:li>002D7F3ADB46353EADA68962ED37C196</rdf:li>
               <rdf:li>00852DB858465CB6429AB608B4015D59</rdf:li>
               <rdf:li>009F245CD7D9312728771BC76E54F77A</rdf:li>
               <rdf:li>00BF221B86F5D38835AA7327C3AA5808</rdf:li>
Title: Re: Using a csv as a source file
Post by: StarGeek on January 20, 2022, 01:05:51 PM
See FAQ #3 (https://exiftool.org/faq.html#Q3).
Title: Re: Using a csv as a source file
Post by: JonAgain on January 20, 2022, 01:23:33 PM
I appreciate your responses but this is all just sending further down the rabbit hole.  Maybe if we could figure why my results csv is empty that would be great.  Otherwise I'll just move on and keep doing what I am doing.