(sorry for my bad english)
Hello everyone, I am organizing huge of image files that store specific data in "UserComment" category.
My goal is, let's say that some image has "Threshold Ratio: 0.N," string like below:
Image1.png - "UserComment: KEY1: VALUE1, KEY2: VALUE2, ...... Threshold Ratio: 0.347, KEY10: VALUE10, ......"
Image2.webp - "UserComment: ...... Threshold Ratio: 0.954, ......"
Image3.jpg - "UserComment: ...... Threshold Ratio: 0, ......"
...
and others does not.
I then want to move these images into folders named with values like "\Ratio_0.347, \Ratio_0.954, \Ratio_0".
This means that I need to find the string "Threshold Ratio: 0.N" in the images in the folder(recursively), and then extract only the "0.N" characters.
How can I achieve it with ExifTools command line?
I had tried to search so many web pages for this feature but failed...
Probably, below very limited information I found seem to be clues to my goal.
- Regular expression: ".+Threshold Ratio: (\S+),.+" Replacement: "$1"
- Similar command, but need to write the value one by one:
" .\exiftool.exe -if '"$exif:UserComment =~ /Threshold Ratio: 0.347/"' ./ -directory=".\Ratio_347\ "
" .\exiftool.exe -if '"$exif:UserComment =~ /Threshold Ratio: 0.954/"' ./ -directory=".\Ratio_954\ "
" .\exiftool.exe -if '"$exif:UserComment =~ /Threshold Ratio: 0/"' ./ -directory=".\Ratio_0\ "
......
Any idea will be very helpful to solve this problem!
Thank you.
The command you would would be something like
exiftool -r -if "$UserCommentl=~/Threshold Ratio:/i" "-Directory<${UserComment;m/Threshold Ratio:\s+0\.(\d+)/i;$_=Ratio_0$1;}" /path/to/files/
The one big question is where do you want the "Ratio_" directories located, especially with a subdirectory and recursion.
If you want to sort them into subdirectories in a specific folder, you would use something like
"-Directory<C:\New\Ratio\directory\${UserComment;m/Threshold Ratio:\s+0\.(\d+)/i;$_=Ratio_0$1;}"
If you want the ratio subdirectories in each of the subdirectories, for example "C:\Pictures\sub1\Ratio_01", "C:\Pictures\sub1\subsub2\Ratio_01", etc, then use
"-Directory<%d${UserComment;m/Threshold Ratio:\s+0\.(\d+)/i;$_=Ratio_0$1;}"
You didn't mention your operating system. These commands would be for Windows CMD. Change the double quotes into single quotes for Mac/Linux.