Hello everyone! I createa new directory according to Headline exif tag and move photos there:
exiftool "-directory<Headline" *.jpg
However pretty often there are special characters like "!", "?", ":" or even new line and tabulation chars like "\n", "\t" etc. Is there any way to remove such characters before creating the directory? Or it is not possible to do so, and I need to modify the name after it's been created?
Thanks in advance!
Try using something like this:
ExifTool "-directory<${Headline;tr/!?:\n\r\t/ /}" *.jpg
That will translate all the characters in the first group into spaces and you can add others if you like. You can change the space to whatever you want. I also added in the CR just in case.
This might lead to a string of spaces. If you don't care for that, you can use this:
ExifTool "-directory<${Headline;tr/!?:\n\r\t/ /;s/ +/ /g}" *.jpg
Edit: minor tweak
Characters that are special in Windows file names are removed by simply doing this in an advanced formatting expression: ${TAG;} This is mentioned in the documentation. I did this because I thought it would be a common usage and escaping these characters is tricky.
- Phil
Hi,
I have problems with EXIFTOOL not finding my folders when they are named with the letters Æ, Ø and Å (Norwegian letters, Windows 10, exe file) I see that the following is mentioned in the documentation regarding this:
The external character set for tag values passed to/from ExifTool is UTF‑8 by default, but it may be changed through any of these command-line options:
-charset CHARSET or -charset exiftool=CHARSET or -L
The encoding of file and directory names (eg. the FILE argument on the command line) is different. By default, these names are passed straight through to the standard C I/O routines without recoding. On Mac/Linux these routines expect UTF‑8, but on Windows they use the system code page (which is dependent on your system settings). However, as of ExifTool 9.79, the external filename encoding may be specified:
-charset filename=CHARSET
I assume I should include the following in my statments: "-charset filename=CHARSET" , but what CHARSET should I use?
Br
Øivind
The CHARSET should be set to the character set you are using. If you are inputting filenames on the command line, then this is the system character set (see FAQ 18 (https://exiftool.org/faq.html#Q18)). But I would recommend using a UTF-8 argfile with the -@ option and setting CHARSET to "utf8".
- Phil