Linux command
convmv 命令
文件
复制后可按需替换文件名、目录或参数。
常用示例
Preview converting filenames
convmv -f latin1 -t utf-8 [path/to/files/*]
Actually convert filenames
convmv -f latin1 -t utf-8 --notest [path/to/files/*]
Convert filenames recursively
convmv -f latin1 -t utf-8 -r --notest [path/to/directory]
Convert from Windows encoding
convmv -f cp1252 -t utf-8 --notest [path/to/files/*]
Lowercase all filenames
convmv --lower --notest [path/to/files/*]
Fix double-encoded UTF-8
convmv --fixdouble -f utf-8 -t utf-8 --notest [path/to/files/*]
说明
convmv is a utility for converting filenames between different character encodings. It's essential when files created on one system with a particular locale need to be used on another system with a different character encoding. Common use cases include migrating files from Windows (using cp1252 or ISO-8859-1) to Linux with UTF-8, or fixing filenames that were created with incorrect encoding assumptions. The tool can also fix double-encoded UTF-8, which occurs when UTF-8 bytes are mistakenly encoded as UTF-8 again. By default, convmv performs a dry run showing what would be changed. The --notest flag must be explicitly provided to actually rename files. This safety feature prevents accidental mass renaming operations.
参数
- -f _ENCODING_
- Source encoding (from encoding).
- -t _ENCODING_
- Target encoding (to encoding).
- -r
- Recurse into subdirectories.
- --notest
- Actually perform the conversion (default is dry run).
- --nfc
- Normalize to Unicode NFC form.
- --nfd
- Normalize to Unicode NFD form.
- --lower
- Convert filenames to lowercase.
- --upper
- Convert filenames to uppercase.
- --fixdouble
- Fix double-encoded UTF-8 filenames.
- --list
- List available encodings.
- --preserve-mtimes
- Preserve modification times on directories.
FAQ
What is the convmv command used for?
convmv is a utility for converting filenames between different character encodings. It's essential when files created on one system with a particular locale need to be used on another system with a different character encoding. Common use cases include migrating files from Windows (using cp1252 or ISO-8859-1) to Linux with UTF-8, or fixing filenames that were created with incorrect encoding assumptions. The tool can also fix double-encoded UTF-8, which occurs when UTF-8 bytes are mistakenly encoded as UTF-8 again. By default, convmv performs a dry run showing what would be changed. The --notest flag must be explicitly provided to actually rename files. This safety feature prevents accidental mass renaming operations.
How do I run a basic convmv example?
Run `convmv -f latin1 -t utf-8 [path/to/files/*]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -f _ENCODING_ do in convmv?
Source encoding (from encoding).