News:

2023-03-15 Major improvements to the new Geolocation feature

Main Menu

How to update filenames w/ brackets, parenthesis and other characters

Started by moreorless, February 04, 2019, 04:13:14 AM

Previous topic - Next topic

moreorless

Hello,

I would like to update the filenames in a folder of mine to just the text and then copy that text to the title tag  However, i have a lot of files with brackets, parenthesis and other characters in the filename. I am using windows ten. I have been looking through the forum for hours and can't seem to find how to remove the brackets.

here are some examples and what result I am trying to get to:

current filename: [Mail] Better Fouls Down.mp4
new filename:     Mail Better Fouls Down.mp4
new title:            Mail Better Fouls Down

current filename: [the-best-day.com] 13-Day Fun(1080p).mp4
new filename:     the best day com 13-Day Fun 1080p.mp4
new title:             the best day com 13-Day Fun 1080p

Hope this makes sense, please let me know if you need more info.

Stephen Marsh

I had a similar question here:

https://exiftool.org/forum/index.php/topic,9400.0.html

moreorless

should the full code be?

exiftool "-filename<${pseudotag;tr/-_0-9a-zA-Z//dc}" DIR

or am i missing another step?

StarGeek

No.  Stephen is using the word pseudotag as a wildcard for any tag he might decide to use. 

In your case, you want do replacements on the filename, so you would change pseudotag to Filename.

So your complete command would be something like:
exiftool "-Filename<${Filename;tr/-_0-9a-zA-Z//dc}" "-Title<${Filename;tr/-_0-9a-zA-Z//dc}" DIR

Another thing to take note of is that in the case of MP4 files, exiftool will only write to the XMP:Title tag as it has limited ability to write video metadata.  Most programs won't read this tag and it won't show up when you look at the Windows->Properties->Details.  You might have to look to use FFMpeg change the Title.

This command creates backup files.  Add the Overwrite_Original option to suppress the creation of backup files.  This command will change the system modify date for affected files.  Add the -P (preserve) to prevent this.  Add the-r option to recurse into subdirectories.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

Stephen Marsh

Following on from StarGeek's reply in the other topic thread, you will need to include the preservation of the period character and word space in the code, so I would suggest:

exiftool "-Filename<${Filename;tr/-_0-9a-zA-Z\. //dc}" "-Title<${Filename;tr/-_0-9a-zA-Z\. //dc}" -r FILEorDIR

StarGeek

This was getting fragmented, so I merged the posts from the other thread into this one.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

StarGeek

Quote from: Stephen Marsh on February 04, 2019, 03:19:27 PM
you will need to include the preservation of the period character and word space in the code, so I would suggest:

Good call.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

moreorless


Stephen Marsh

For what it is worth, as I don't fully understand the syntax of Phil's original piece of Perl transliteration (otherwise known as voodoo magic), for me the following equivalent uses a more familiar regex pattern (a negated character class/set using the global flag):

exiftool "-filename<${filename;s/[^-_0-9a-zA-Z\. ]//g}" "-title<${filename;s/[^-_0-9a-zA-Z\. ]//g}" -r FILEorDIR

StarGeek

It was pretty much voodoo to me as well.  I knew that the tr command would translate 1 character into another.  But I didn't know there were trailing options for it.

For example, to do a Rot13 (rotate 13), it can be used like this
tr/A-Za-z/N-ZA-Mn-za-m/
This converts A to N (13 characters later), B to O, etc.

The trailing C is for complement.  So it takes the inverse of what's in the first set.  The trailing D is for delete.  It just deletes any characters not in the first set, which in this case has been inverted.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

Stephen Marsh

Thank you StarGeek, I truly appreciate that you took the time to answer such an obscure point. For me, the standard negated regex is easier to follow! :]