Command line - Windows : exiftooling paths listed in a txt file

Started by sylf, December 12, 2021, 09:13:15 AM

Previous topic - Next topic

sylf

Hello.

This command line :

@ECHO OFF
for /r C:\dir1\dir2\dir3 %%Y in (*.jpg *.jpeg *.JPG *.JPEG *.tif *.tiff *.TIF *.TIFF) do (
exiftool.pl -X %%Y > C:\dir1\dir2\%%~nY.xml)

... goes through a directory, takes one image file at a time, exiftools it and outputs an xml file with metadata. This is nice !

Instead of going through a directory, I want now my complete paths to be extracted from a txt file like this :

C:\dir1\a.jpg
C:\dir2\dir1\b.jpg
C:\dir3\dir1\dir4\c.tif

Each path (= each line in my txt file) should replace "C:\dir1\dir2\dir3" one by one in the script above.

I found some ideas like https://stackoverflow.com/questions/155932/how-do-you-loop-through-each-line-in-a-text-file-using-a-windows-batch-file, but could not apply them with success.

Any help very welcome :)

S

Phil Harvey

This looks like common mistake #3 to me.  Launching ExifTool separately for each file is very slow.

If you have all the file paths, one per line in a text file (let's call it "file_list.txt"), you would do something like this:

exiftool -@ file_list.txt -X -w %d%f.xml

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

sylf

Phil,
Happy with this so simple solution to my common mistake #3 :)
By the way, I have many paths with spaces like :
C:\dir name 1\a.jpg
C:\dir2\dir1\file name b.jpg
C:\dir name 2\dir1\file name b.jpg

I looked for solutions. For the Command line on Windows, it is said that escaping ways like putting "^" before the space or double-quoting either the entire path or only the concerned section (example : C:\"dir name 1"\a.jpg) should sometimes work. But, in my case, it failed.
If you had any comment on that, I would pay attention.
Thank you.
Sylvain

StarGeek

Quote from: sylf on December 12, 2021, 10:03:58 AMFor the Command line on Windows, it is said that escaping ways like putting "^" before the space or double-quoting either the entire path or only the concerned section

You would do this on the command line but when exiftool reads a text file with the -@ (Argfile) option, there should be no quotes or escape characters. The text file should be exactly as you listed
C:\dir name 1\a.jpg
C:\dir2\dir1\file name b.jpg
C:\dir name 2\dir1\file name b.jpg
"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

sylf

Well, I just tried, StarGeek...
And I confirm... this is true !
So good :)