LinuxCommandLibrary

convmv

Convert file names from one encoding to another

TLDR

Test filename encoding conversion (don't actually change the filename)

$ convmv -f [from_encoding] -t [to_encoding] [input_file]
copy

Convert filename encoding and rename the file to the new encoding
$ convmv -f [from_encoding] -t [to_encoding] --notest [input_file]
copy

SYNOPSIS

convmv [options] file(s)/directory(s)

PARAMETERS

-f ENCODING
    Source encoding. Specifies the encoding the filenames are currently in.

-t ENCODING
    Destination encoding. Specifies the encoding you want to convert the filenames to.

-r
    Recursive. Processes all files and subdirectories within the specified directories.

--notest
    No test mode. Executes the changes without prompting for confirmation. Careful use is advised.

--list
    Lists all supported encodings.

--unescape
    Unescape percent-encoded characters in filenames.

--replace
    Replace characters in filenames when conversion fails. Requires caution as data loss is possible

--exec COMMAND
    Executes a command for each file or directory after conversion. Use with caution, especially when dealing with special chars and spaces. Use {} as placeholder

--shell
    Use shell for command execution. Same as --exec "sh -c COMMAND". Use with caution, especially when dealing with special chars and spaces.

DESCRIPTION

The convmv command converts filenames from one encoding to another. This is particularly useful when dealing with files created under different operating systems or with older software that used different character encodings. convmv attempts to handle directory trees recursively and offers dry-run modes to preview changes before committing them.
It's crucial to back up your data before using convmv, especially on critical systems, as incorrect usage could lead to data loss or corruption. convmv isn't perfect and relies on character set mappings to correctly translate characters; some characters might not have direct equivalents, potentially leading to lossy conversions.

CAVEATS

Incorrect usage can lead to data loss or corruption. It's crucial to back up your data before using this command. Some characters might not have direct equivalents in the target encoding, potentially leading to lossy conversions.

EXIT STATUS

convmv returns 0 on success, and >0 if any error occurred.

EXAMPLES

  • Preview conversion from Latin1 to UTF-8: convmv -f latin1 -t utf8 -r --notest ./directory
  • Perform conversion: convmv -f latin1 -t utf8 -r ./directory

SEE ALSO

iconv(1), rename(1)

Copied to clipboard