Exif Export to CSV -- duplicate Headerinformation

Started by emja, November 03, 2022, 06:56:19 AM

Previous topic - Next topic

emja

Hi, i've got a question for the csv Export.

Forum.Search takes me to ather topics (GPS .. ) and custom Headernames ..

Problem:
find * -name "*.pdf" -mmin +10 | xargs -I '{}' exiftool -csv -Title -FileSize >> QM_List.csv {}

I want to list pdf-files after export, but no duplicated filename in the QM_List. (Thats why the pipe)
All fine at all.

But;

SourceFile,Title,FileSize \LF
Val1,val2,val3 \LF

comes always before the Exif-Values.

Is there an option to write the Header only in the first line?

Ver= 12.42 / centos

Phil Harvey

The way to do this is to run ExifTool only once.  What exactly are your "find" and "xargs" commands doing?  You should be able to do this using ExifTool (see common mistake #3).

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

emja

#2
Hi Phil,
thanks a lot for your answer.

I hope i get yout point correctly.
But i can't find a way to filter changedate like (less than a minute) ...

This is my try  ... but "files failed condition"; is there a condition to compare tag like FileModifyDate with current timestamp+/- min,hours, days ?

exiftool -FileModifyDate -if "$FileModifyDate > '$DateTimeOriginal' " -csv -Title -FileSize >QM_List.csv -ext pdf -r .


###############################

Thank you for this great forum.



Phil Harvey

ExifTool provides a "ShiftTime" helper function.  From the documentation:

       "ShiftTime"

       Shifts EXIF-formatted date/time string by a specified amount.  Start
       with a leading minus sign to shift backwards in time.  See
       Image::ExifTool::Shift.pl for details about shift syntax.  For example,
       to shift a date/time value back by one year:

           exiftool -p '${createdate;ShiftTime("-1:0:0 0")}' a.jpg


So you can do something like this:

exiftool -FileModifyDate -if "${FileModifyDate;ShiftTime('-0:1')} gt $DateTimeOriginal" -csv -Title -FileSize -ext pdf -r . >QM_List.csv

For example, here I'm shifting FileModifyDate back by 1 minute and comparing to DateTimeOriginal.  You must use the Perl string comparisons (gt, lt, ge, le, eq, ne) and not the numerical comparison operators (>, <, >=, <=, == !=).  I'm using Windows CMD quoting because you seem to have switched to Windows in your last example.

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

StarGeek

#4
Quote from: emja on November 03, 2022, 06:56:19 AMIs there an option to write the Header only in the first line?

Exiftool can't exclude the header line using the -csv option so that you can append the new file list to the previous CSV.

There are a couple of options, though.  You can roll your own CSV format using the -n (--printConv) option.  See near the end of FAQ #12.

You could also pipe through tail as in this StackOverflow Answer.

While Phil is correct that you could probably use exiftool directly, I don't think FAQ 3 is a problem here.  I'm not really familiar with linux commands but it looks like you're creating a file list with find and directly passing that list to exiftool via STDIN.  That would avoid looping and running exiftool once per file, which is the big performance hit.

Looking closer, I think you can drop the xargs part as exiftool can read directly from STDIN by using a  -  Correction, using the -@ (Argfile) option along with a -.  Something like
find * -name "*.pdf" -mmin +10 | exiftool -csv -Title -FileSize -@ - >> QM_List.csv

I think in your case, piping through tail would work fine.  So the final command could be like this(?)  I'm not sure how tail works with piping, so some editing may be required.
find * -name "*.pdf" -mmin +10 | tail -n +2 | exiftool -csv -Title -FileSize -@ - >> QM_List.csv

While I love exiftool and always advocate it, I like the cleanness of a linux command like this over the more complex exiftool command.
"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

Quote from: StarGeek on November 05, 2022, 11:19:06 AMfind * -name "*.pdf" -mmin +10 | exiftool -csv -Title -FileSize - >> QM_List.csv

I think you may need -@ - instead of just - in the exiftool arguments.

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

StarGeek

"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

emja

Thank you Phil, Thank you StarGeek !

Its amazing, both ways work fine.

-@ -                        = great new for me
Image::ExifTool::Shift.pl   = is a fantasic new possibility


Exiftool is great universe. For me as an exiffool, i'm very thankful for your help.