ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: sylf on February 02, 2024, 11:03:21 AM

Title: Batch processing of files with the same name but not the same extension
Post by: sylf on February 02, 2024, 11:03:21 AM
Hello.
I have a text file with hundreds of lines. Each line is the full path of a file to be processed by this ExifTool command:
exiftool -@ path1\file_list.txt -X -w path2\%d%f.xmlOften, in an input folder, I have files with the same name but not the same extension. Example: test1.jpg and test1.tif.
In these cases, ExifTool processes only one of the files and I get only one xml file as output. Of course, I need one xml file per input file.
What would be the way to reach my goal?
Kind regards.

Title: Re: Batch processing of files with the same name but not the same extension
Post by: StarGeek on February 02, 2024, 11:47:14 AM
How do you want to name the duplicate XML files?  Obviously, you can't have two XML files with the same name for each of the test1.jpg/test1.tif.

You might change the XML file name to include the extension.
exiftool -@ path1\file_list.txt -X -w path2\%d%f.%e.xml

You could also use a copy number %c instead of the extension %e but then you don't have a way to tell which XML file belongs to the tiff or the jpg.

See the -w (-TextOut) option (https://exiftool.org/exiftool_pod.html#w-EXT-or-FMT--textOut) for details on the percent variables.
Title: Re: Batch processing of files with the same name but not the same extension
Post by: sylf on February 02, 2024, 12:28:37 PM
Thank you StarGeek!
In case this might be useful to someone. In the command:
exiftool -@ path1\file_list.txt -X -w path2\%d%f%+c.xmland precisely in "%+c", "+" adds an underscore before the copy number. Output will be: "test1.xml" and "test1_1.xml".
But I think you are right, StarGeek, adding the extension is a good idea.
You are proposing this output: "test1.jpg.xml" and "test1.tif.xml". But I have some superstition that prevents me from putting a dot in filenames except before the extension, of course. Do you have any religion on the subject? Personally, I am used to insert "_" as a separator.
Title: Re: Batch processing of files with the same name but not the same extension
Post by: Phil Harvey on February 02, 2024, 12:40:39 PM
If you don't want 2 dots in teh name, you could do this:

-w path2\%d%f_%e.xml

- Phil
Title: Re: Batch processing of files with the same name but not the same extension
Post by: sylf on February 02, 2024, 12:48:08 PM
Thank you, Phil.
If you or anyone here would like to comment my superstition of not putting dots in filenames, I would be interested.
Title: Re: Batch processing of files with the same name but not the same extension
Post by: Phil Harvey on February 02, 2024, 12:56:16 PM
Multiple dots in filenames are fairly common nowadays.  I haven't had any problems with it, but I'm on a Mac and things may be different for Windows.

- Phil
Title: Re: Batch processing of files with the same name but not the same extension
Post by: sylf on February 02, 2024, 01:21:53 PM
Thank you again, Phil.
Windows and Linux Users: any comments on the use of dots in filenames are welcome here. Although I admit that it is not an ExifTool issue.