In bash, I use a script to collect metadata from all files in a folder structure.
Basicly, the command to run is like:
find /<path>/ -type f -print0 | sort -z | xargs -0 exiftool -n -m -p '"$Directory";"$FileName";"$DateTimeOriginal";"$Tagslist"'
In some cases, exiftool returns:
Error: Error opening file - /<path>/DIR/SUBDIR/SUBSUBDIR/DNG/FILENAME.dng.xmp
(File [FILENAME.dng] is present in the same folder.)
This happens only for .dng.xmp files that has a .jpg file with identical name in its parent directory, i.e. a file named [FILENAME.jpg] in directory "/<path>/DIR/SUBDIR/SUBSUBDIR/". The .dng.xmp that don't have a corresponding .jpg in its parent directory always works.
Using the command with find pointing directly to the DNG-directory will not cause the errror, in this case exiftool opens the file and reads its metadata:
find /<path>/DIR/SUBDIR/SUBSUBDIR/DNG/ -type f -print0 | sort -z | xargs -0 exiftool -n -m -p '"$Directory";"$FileName";"$DateTimeOriginal";"$Tagslist"'
A strange thing is that this not happens on all folder structures paths, some works just fine (I have tried with identical structures on different paths). Sometimes, but not always, cd into the folder structure works for exiftool. E.g. this might cause exiftool to find the files:
cd /<path>/DIR/
find SUBDIR/ -type f -print0 | sort -z | xargs -0 exiftool -n -m -p '"$Directory";"$FileName";"$DateTimeOriginal";"$Tagslist"'
The only common thing with directories that sometimes does not work is that they are mounted samba shares.
What is wrong here? :)
All help appreciated...
We have seen some similar problems (especially recently) on Windows shared drives that have been solved by adding this to the exiftool command:
-api WindowsWideFile=1 -charset filename=utf8
- Phil
Thanks, but unfortunately it makes no difference :(
The file is not read and meta data is blank in the result.
A complete command:
find /media/delat/Media/Fotografier/fotostruktur/01_album/2023/20230909bFF_FjällvandringJämtlandstriangeln/20230912FF_Tisdag-VilodagSylarna/20230912e_Norrsken/ -type f -print0 | sort -z | xargs -0 exiftool -api WindowsWideFile=1 -charset filename=utf8 -n -m -p '"$Directory";"$FileName";"$DateTimeOriginal";"$Model";"$Rating"' | grep 225530.dng.xmp
Output:
Error: Error opening file - /media/delat/Media/Fotografier/fotostruktur/01_album/2023/20230909bFF_FjällvandringJämtlandstriangeln/20230912FF_Tisdag-VilodagSylarna/20230912e_Norrsken/DNG/20230912-225536_AL-SMG780G_20230912_225530.dng.xmp
Error: Error opening file - /media/delat/Media/Fotografier/fotostruktur/01_album/2023/20230909bFF_FjällvandringJämtlandstriangeln/20230912FF_Tisdag-VilodagSylarna/20230912e_Norrsken/DNG/20230912-230246_AL-SMG780G_20230912_230241.dng.xmp
Error: Error opening file - /media/delat/Media/Fotografier/fotostruktur/01_album/2023/20230909bFF_FjällvandringJämtlandstriangeln/20230912FF_Tisdag-VilodagSylarna/20230912e_Norrsken/DNG/20230912-230533_AL-SMG780G_20230912_230528.dng.xmp
64 image files read
"/media/delat/Media/Fotografier/fotostruktur/01_album/2023/20230909bFF_FjällvandringJämtlandstriangeln/20230912FF_Tisdag-VilodagSylarna/20230912e_Norrsken/DNG";"20230912-225536_AL-SMG780G_20230912_225530.dng.xmp";"";"";""
While a read directly into the folder where the DNG resides works:
find /media/delat/Media/Fotografier/fotostruktur/01_album/2023/20230909bFF_FjällvandringJämtlandstriangeln/20230912FF_Tisdag-VilodagSylarna/20230912e_Norrsken/DNG/ -type f -print0 | sort -z | xargs -0 exiftool -api WindowsWideFile=1 -charset filename=utf8 -n -m -p '"$Directory";"$FileName";"$DateTimeOriginal";"$Model";"$Rating"' | grep 225530.dng.xmp
Output:
27 image files read
"/media/delat/Media/Fotografier/fotostruktur/01_album/2023/20230909bFF_FjällvandringJämtlandstriangeln/20230912FF_Tisdag-VilodagSylarna/20230912e_Norrsken/DNG";"20230912-225536_AL-SMG780G_20230912_225530.dng.xmp";"";"SM-G780G";"2"
exiftool version is 12.76
Any other ideas?
Your filenames dont look like Windows filenames. The -Api WindowsWideFile only works for Windows!
Is there a specific reason for using the null separator options? And I assume there's a reason for using find instead of letting exiftool process the directory itself? Symlinks maybe?
What happens if you pass the results directly to exiftool using the -@ (Argfile) option (https://exiftool.org/exiftool_pod.html#ARGFILE), i.e. using -@ - takes input directly from the pipe
find /media/delat/Media/Fotografier/fotostruktur/01_album/2023/20230909bFF_FjällvandringJämtlandstriangeln/20230912FF_Tisdag-VilodagSylarna/20230912e_Norrsken/DNG/ -type f | sort | exiftool -@ - -n -m -p '"$Directory";"$FileName";"$DateTimeOriginal";"$Model";"$Rating"'
Quote from: StarGeek on November 01, 2024, 05:45:16 PMIs there a specific reason for using the null separator options? And I assume there's a reason for using find instead of letting exiftool process the directory itself? Symlinks maybe?
Tested that as well,
exiftool -r -n -m -p '"$Directory";"$FileName";"$DateTimeOriginal";"$Model";"$Rating"' /media/delat/Media/Fotografier/fotostruktur/01_album/2023/20230909bFF_FjällvandringJämtlandstriangeln/20230912FF_Tisdag-VilodagSylarna/20230912e_Norrsken/ gives the same errors.
Quote from: StarGeek on November 01, 2024, 05:45:16 PMWhat happens if you pass the results directly to exiftool using the -@ (Argfile) option (https://exiftool.org/exiftool_pod.html#ARGFILE), i.e. using -@ - takes input directly from the pipe
find /media/delat/Media/Fotografier/fotostruktur/01_album/2023/20230909bFF_FjällvandringJämtlandstriangeln/20230912FF_Tisdag-VilodagSylarna/20230912e_Norrsken/DNG/ -type f | sort | exiftool -@ - -n -m -p '"$Directory";"$FileName";"$DateTimeOriginal";"$Model";"$Rating"'
It is the same result, the path directly into
../DNG/ works but a path any level above causes exiftool to produce the "Error -Opening file..." for those files in DNG/ that has a jpg-file with the same name in its parent directory.
(Except that the suggested command also produce an additonal "Error: File not found -").
I run exiftool version 12.78 at ubuntu 24.04.
The path used is a samba mounted drive (cifs).
The same command works without errors on an identical folder structure on a locally mounted disk (file system ntfs).
Sorry for not having the time to properly respond to this earlier. I was busy trying to fix some file name problems in Windows and had this on my mind.
I don't have a samba share so I can't reproduce this issue, but it could come down to what xargs is passing to ExifTool. Can you attach the "out.txt" file from this command and tell me which file(s) ExifTool isn't able to read?:
find /media/delat/Media/Fotografier/fotostruktur/01_album/2023/20230909bFF_FjällvandringJämtlandstriangeln/20230912FF_Tisdag-VilodagSylarna/20230912e_Norrsken/ -type f -print0 | sort -z | xargs -0 > out.txt
BTW, what system type is the samba server? Windows? If so we may still be dealing with a Windows file name issue here. You're starting to get close to the Windows path length limit with these file names.
- Phil
Thanks for the response and sorry for late reply.
I did make a workaround by using another path to the same directory, which worked.
The samba server is on Linux (Ubuntu server).
I will try the suggested command when I am back home (currently traveling).
Thanks :)