Page 1 of 1

Replace the Characters

Posted: 19 Mar 2019, 18:07
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

Re: Replace the Characters

Posted: 19 Mar 2019, 20:36
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

Re: Replace the Characters

Posted: 20 Mar 2019, 23:11
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...

Re: Replace the Characters

Posted: 21 Mar 2019, 05:17
by rednoah
As a colon : replacement, I'd recommend ratio ∶
https://unicode-table.com/en/2236/

Re: Replace the Characters

Posted: 21 Mar 2023, 20:59
by jaytee
Any similar suggestions for multiple replacements? eg something for ? AND something for ; AND the colon suggested?

Re: Replace the Characters

Posted: 22 Mar 2023, 02:13
by rednoah
e.g. Custom Character Replacement

Code: Select all

{
	n.replace(
		':' : '',
		'-' : '',
		'&' : 'and'
	)
}