detox
Clean filenames of potentially problematic characters
TLDR
Remove spaces and other undesirable characters from a file's name
Show how detox would rename all the files in a directory tree
Remove spaces and other undesirable characters from all files in a directory tree
SYNOPSIS
detox [OPTION]... [FILE]...
PARAMETERS
-h, --help
Print help information and exit
-V, --version
Print version information and exit
-n, --dry-run
Simulate actions without modifying files (combine with -v)
-v, --verbose
Print details of actions to stderr
-q, --quiet
Suppress all non-error messages
-r, --recursive
Recursively process directories
-f, --force
Process all files, even if already detoxed
-s SCHEME, --scheme=SCHEME
Select cleaning scheme (default: unix)
-l FILE, --log-file=FILE
Log processed files to FILE
-a FILE, --after-file=FILE
Process files modified after FILE's timestamp
DESCRIPTION
Detox is a versatile command-line utility for cleaning filenames, making them compatible with various filesystems and operating systems. It replaces or removes problematic characters such as spaces, control codes, non-ASCII symbols, and shell metacharacters that can cause issues during processing, backups, or transfers.
By default, detox uses the unix scheme, converting spaces to underscores, removing certain punctuation, and truncating overly long names. Users can select from multiple schemes like windows, iso8859-1, utf_8, and custom configurations via a file.
Common use cases include sanitizing downloaded archives, preparing files for version control, or batch-renaming media libraries. It supports recursive processing of directories, dry-run simulations to preview changes, verbose output for monitoring, and logging for audits. Detox operates in-place but safely skips already clean files, preserving original names when possible.
Unlike simple scripts, detox handles edge cases like duplicate names intelligently and supports internationalization, ensuring broad applicability across Unix-like systems.
CAVEATS
Modifies files in-place; use -n for testing. May alter names irreversibly—backup critical data. Not suitable for all locales without proper scheme.
SUPPORTED SCHEMES
unix (default), windows, windows-1250, iso8859-1, l1, utf_8, custom (via file). See detox -s ? for list.
CUSTOM SCHEME
Define via ~/.detoxrc or -s file://path/to/scheme.rc with rules like sequence SPACE '_';
HISTORY
Created by Douglas Thrift in 2001 as a Perl script for filename sanitization. Ported to C for performance, now maintained on GitHub with ongoing scheme updates and bug fixes since 2010s.


