Page 1 of 1

[SNIPPET] Replace Characters, Words or Patterns

Posted: 07 Apr 2023, 05:41
by rednoah
:!: Note that most software expects the file name and the database entry to match exactly. If you modify the movie name / series name with custom character replacements, then FileBot and any other 3rd party software (e.g. Plex, Kodi, Emby, Jellyfin, etc) may have trouble making sense of the file name in the future. :!:



e.g. Replace custom text:

Format: Select all

{ n.replace('apple':'orange') }


e.g. Strip : and - and replace & with and:

Format: Select all

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


e.g. Replace German Umlauts:

Format: Select all

{ n.replace(ä:'ae', ö:'oe', ü:'ue') }


e.g. Read replacement map from an external CSV or TSV file:

Format: Select all

{ n.replace(csv('/path/to/replace.csv')) }

Console Output: Select all

$ cat ~/replace.csv
ä	ae
ö	oe
ü	ue





e.g. Remove all patterns in (...) round brackets:

Format: Select all

{ fn.removeAll(/\(.+?\)/) }
e.g. Remove all patterns in [...] square brackets:

Format: Select all

{ fn.removeAll(/\[.+?\]/) }
:arrow: See Strip brackets [...] from the file path for details.