dbr / tvnamer

Automatic TV episode file renamer, uses data from thetvdb.com via tvdb_api
https://pypi.python.org/pypi/tvnamer/
The Unlicense
907 stars 115 forks source link

[Request] Filenames without whitespace #171

Closed alienbogart closed 4 years ago

alienbogart commented 4 years ago

Is there an option to create filenames without whitespaces? If there isn't may I suggest this feature?

Thanks!

dbr commented 4 years ago

Sorry for the slow reply! There's a few options which can be used to do this, the simplest is to blacklist the space character,

{"custom_filename_character_blacklist": " ",
 "replace_invalid_characters_with": "_"}

This will replace spaces and any other invalid characters with an underscore (the underscore is the default value for that option, so could be omitted in this example)

You can also use the output_filename_replacements option to do this more specifically,

{
    "output_filename_replacements": [
        {"is_regex": false,
        "match": " ",
        "replacement": "_"}
    ]
}

More examples of this at https://github.com/dbr/tvnamer/blob/master/tests/test_custom_replacement.py