ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: gcue on April 19, 2016, 09:48:07 AM

Title: querying/writing tag to a list of files (batch processing)
Post by: gcue on April 19, 2016, 09:48:07 AM
hello

is it possible to write or query a tag to a list of files.. perhaps specified through a text file?

thank you in advance
Title: Re: querying/writing tag to a list of files (batch processing)
Post by: Phil Harvey on April 19, 2016, 12:03:09 PM
Yes.
Title: Re: querying/writing tag to a list of files (batch processing)
Post by: gcue on April 19, 2016, 12:19:53 PM
what does the syntax look like?  can you provide an example?

thanks again
Title: Re: querying/writing tag to a list of files (batch processing)
Post by: Phil Harvey on April 19, 2016, 12:27:08 PM
You'll have to narrow things down a bit.  Your question is too vague.  Do you want to read or write?  What tags?  What format text file?

- Phil
Title: Re: querying/writing tag to a list of files (batch processing)
Post by: gcue on April 19, 2016, 12:34:15 PM
sorry about being vague.. :-[

i am trying to read the DateTimeOriginal tag for several thousand files.  i am going to output the file paths to a text file.  so each line would look something like this..

c:\users\smith\desktop\folder\file1.jpg
c:\users\smith\desktop\folder\folder2\file1.jpg
c:\users\jones\desktop\folder\folder7\file1.jpg

i would also like to be able to write the same tag to multiple files as well.

please let me know if i need to specify anything else

thanks again

Title: Re: querying/writing tag to a list of files (batch processing)
Post by: Phil Harvey on April 19, 2016, 01:29:54 PM
So you want to read DateTimeOriginal for all files listed in a text file?  This command will do it:

exiftool -datetimeoriginal -@ file_list.txt

and to write instead of read:

exiftool "-datetimeoriginal=2016:04:19 13:29:00" -@ file_list.txt"

- Phil
Title: Re: querying/writing tag to a list of files (batch processing)
Post by: gcue on April 19, 2016, 02:24:34 PM
that worked!  ;D

thank you for your quick help but most of all... thank you for the AWESOME tool!!!

truly a masterpiece
Title: Re: querying/writing tag to a list of files (batch processing)
Post by: gcue on April 22, 2016, 09:19:45 AM
for the write... is it possible to include unique dates for each entry in the text file?

thanks again!
Title: Re: querying/writing tag to a list of files (batch processing)
Post by: Phil Harvey on April 23, 2016, 10:09:35 PM
Yes.  For this you should look at the -csv option.

- Phil
Title: Re: querying/writing tag to a list of files (batch processing)
Post by: gcue on April 23, 2016, 10:43:28 PM
So glad it can do it. What is the syntax like?  Is it the same as the text file command?  Csv file... first column file path, second column tag and third date/time?

Thank you again for your help
Title: Re: querying/writing tag to a list of files (batch processing)
Post by: gcue on April 25, 2016, 12:25:12 PM
found an example in the forum =)

csv
QuoteSourceFile,DateTimeOriginal
C:\Users\Smith\Desktop\New folder1\IMG_0066.JPG,2016:03:07 10:29:00
C:\Users\Smith\Desktop\New folder1\IMG_3894 (1).JPG,2016:03:07 10:20:01

command i am using
exiftool -csv="C:\Users\Smith\Desktop\tags.csv" -r "C:\Users\Smith\Desktop\New folder1"

i am curious why this is needed
-r "C:\Users\Smith\Desktop\New folder1"

since the location of each file is already specified in the SourceFile column?

thanks again!
Title: Re: querying/writing tag to a list of files (batch processing)
Post by: Phil Harvey on April 26, 2016, 01:45:11 PM
Quote from: gcue on April 25, 2016, 12:25:12 PM
since the location of each file is already specified in the SourceFile column?

Because you specify the files to process on the ExifTool command line for all other types of commands, and I thought it would be confusing to make this different.

- Phil
Title: Re: querying/writing tag to a list of files (batch processing)
Post by: gcue on April 26, 2016, 05:21:28 PM
gotcha ... consistency is good =)

is there a limit with how many files are processed through the txt or csv file?

thanks again for sharing such a powerful program
Title: Re: querying/writing tag to a list of files (batch processing)
Post by: Phil Harvey on April 28, 2016, 08:27:47 AM
There is no limit.

- Phil
Title: Re: querying/writing tag to a list of files (batch processing)
Post by: gcue on August 09, 2016, 05:17:19 PM
i think i may have found a bug?

if the file_list.txt for the -@ switch happens to have only 1 file path it doesn't work

no output or error

i would think it should work because sometimes it's unpredictable how many file paths we can expect there to be in the text file if the text file is generated through a script process

thanks!
Title: Re: querying/writing tag to a list of files (batch processing)
Post by: Phil Harvey on August 10, 2016, 07:44:41 AM
It should work fine with just one line in the -@ argfile.  There must be something else going on.  Post your full command and the argfile and we'll try to help.

- Phil
Title: Re: querying/writing tag to a list of files (batch processing)
Post by: gcue on August 10, 2016, 09:23:35 AM
Quotecommand:
exiftool -UserComment -DateTimeOriginal -GPSPosition -@ list.txt

list.txt:
C:\Users\Smith\Desktop\New folder1\IMG_3799.jpg

if i add another entry to list.txt i get output but i dont get anything with just one entry.

thanks!
Title: Re: querying/writing tag to a list of files (batch processing)
Post by: Phil Harvey on August 10, 2016, 09:54:58 AM
I can't see anything wrong, but you didn't attach the list.txt file and some hidden characters may be significant.

I tried it with no extra characters in list.txt (ie. no leading UTF-8 BOM and no linefeed at the end of the line), and it worked fine.

I would like to find the reason for this, but a work-around may be to add a blank line to the file.

- Phil
Title: Re: querying/writing tag to a list of files (batch processing)
Post by: gcue on August 10, 2016, 10:07:36 AM
i dont see any hidden characters or extra spaces

i tried adding an extra few blank lines - still nothing (no error no output)

using current version of exiftool 10.2.5

thanks for your help
Title: Re: querying/writing tag to a list of files (batch processing)
Post by: Phil Harvey on August 10, 2016, 10:12:24 AM
I can't reproduce this problem.  I just tried it with your list.txt file and got this (on Windows 10 with ExifTool 10.25):

"File not found: C:/Users/GXM/Desktop/New folder1/IMG_3799.jpg"

And it worked fine when I changed the file to one that existed.

So I have no idea why this doesn't work for you.  Your file had no extra hidden characters.  There must be something else going on here.

But maybe try my idea of adding a blank line to the .txt file

- Phil
Title: Re: querying/writing tag to a list of files (batch processing)
Post by: gcue on August 10, 2016, 10:24:49 AM
i tried adding a blank line.. even a few.. still no luck =/

running windows 7 64bit
Title: Re: querying/writing tag to a list of files (batch processing)
Post by: Phil Harvey on August 10, 2016, 11:30:09 AM
This makes absolutely no sense.  I can see no way that a single file in the -@ argfile could ever be ignored.  Maybe try adding -v to the command line to see if there are any messages that could yield a clue.

- Phil

Edit:  Oh, wait.  There will be no output for a single input file if the tags don't exist.  And ExifTool only gives the "### image files read" message if there was more than one file specified.  This must be what you are seeing.  Try it on a file where these tags exist.  This is the same behaviour if the files are specified on the command line, and has nothing to do with the -@ option.
Title: Re: querying/writing tag to a list of files (batch processing)
Post by: gcue on August 10, 2016, 11:39:45 AM
that worked =)

i guess i expected something different because if you run 2 files where the tags don't exist you still get an output: each of the file paths

to be consistent, would it be easy to incorporate that?

nice catch!
Title: Re: querying/writing tag to a list of files (batch processing)
Post by: Phil Harvey on August 10, 2016, 11:47:30 AM
A majority of the time people run exiftool on a single file, and for this case the extra messages are superfluous, so reducing clutter trumps consistency in this case.

Maybe the -progress option will give you what you want?

- Phil
Title: Re: querying/writing tag to a list of files (batch processing)
Post by: gcue on August 10, 2016, 12:01:45 PM
yes i think so, i just have to parse out the [#/#] somehow with stringregexp or something

thanks for all your help