For keeping files consistently named.
- Replaces special characters, non-printing characters, whitespace etc. and produces a Capitalised_Snake_Case filename.
- Some replacements are designed to show what was replaced, e.g.
&becomes_and_for readability. - Others just remove characters altogether, e.g.
filename_.extbecomesfilename.ext. - Extensions and the dirname are not modified (by default) so you can safely do
mv -u file $(sanitise_filename file)for renaming. - Relies on the boost regex library and makes use of modern C++23 features
A bash script that renames your files and folders automatically using the sanitise_filename program to do the string manipulation.
- Pass -k|--keepcase to preserve the original case of your filenames.
- The script calls sanitise_filename with -n (no extension) for directories so that
mvsan *etc. work as expected. - The
mvcommand used internally is called with -n so files won't be overwritten if a sanitised filename conflicts with an existing file.