Replace the Characters

Any questions? Need some help?
Post Reply
Sarah30
Posts: 1
Joined: 19 Mar 2019, 16:04

Replace the Characters

Post by Sarah30 »

Hello,

Is there a possible way to replace the invalid characters in name while renaming with another characters?

For example, when renaming we see that :, ? etc. are invalid characters... so Filebot omits those characters. Now, instead of deleting those characters, can I replace colon (:) with dash (-) or question mark (?) with a exclamation mark (!) and so on?

Thanks
This is my Territory.....Be on your way
User avatar
rednoah
The Source
Posts: 22898
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Replace the Characters

Post by rednoah »

Yes, a few of the examples do just that:
https://www.filebot.net/naming.html

e.g.

Code: Select all

n.replace('?', '!')

Code: Select all

n.colon(' - ')

Code: Select all

t.removeAll(/[!?.]+$/)

Best to just use the {plex} binding though, because it does all of these cleanup operations implicitly:
viewtopic.php?f=5&t=4116
:idea: Please read the FAQ and How to Request Help.
devster
Posts: 417
Joined: 06 Jun 2017, 22:56

Re: Replace the Characters

Post by devster »

If you want to be really fancy you can replace as follows:

Code: Select all

":" > ":"
"?" > "﹖"
Those are single characters, but it's possible it breaks... stuff...
I only work in black and sometimes very, very dark grey. (Batman)
User avatar
rednoah
The Source
Posts: 22898
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Replace the Characters

Post by rednoah »

As a colon : replacement, I'd recommend ratio ∶
https://unicode-table.com/en/2236/
:idea: Please read the FAQ and How to Request Help.
jaytee
Posts: 3
Joined: 02 Nov 2020, 11:28

Re: Replace the Characters

Post by jaytee »

Any similar suggestions for multiple replacements? eg something for ? AND something for ; AND the colon suggested?
User avatar
rednoah
The Source
Posts: 22898
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Replace the Characters

Post by rednoah »

e.g. Custom Character Replacement

Code: Select all

{
	n.replace(
		':' : '',
		'-' : '',
		'&' : 'and'
	)
}
:idea: Please read the FAQ and How to Request Help.
Post Reply