I have Kubuntu 22.04. Is there a program, script, etc. in *buntu that can rename all files in a folder with non-Latin characters to their Latin equivalent? For example, I have a folder that contains files with names like:
Andúril
Dúnedain
Éomer
and I need to rename them to:
Anduril
Dunedain
Eomer
Off the top of my head, Perl's
Text::Unidecode
module can do this (technically it will attempt to transliterate Unicode characters outside of ASCII's range into a suitable ASCII replacement):Most conveniently, you could combine this with the Perl-based
rename
utility and do the following:This will perform a dry-run (no filename will be changed but the result of the substitution for each file will be displayed); if you're happy with the result, remove the
-n
flag:The
-u
option is important as it will tellrename
/ Perl to treat filenames as UTF-8-encoded strings.My usual go-to for this type of things is a program called
detox
. It’s packaged on Ubuntu (and most other Linux distros) in a package of the same name.The default behavior of the command will not actually entirely do what you want, as the primary purpose of the command is to get rid of shell metacharacters in file names, and the current version has shifted away from collapsing things down to ASCII since that is by definition lossy and modern filesystems have no issues with UTF-8 filenames.
However, on Debian, Ubuntu, and many other distros, it still includes the old translation tables that do essentially exactly what you want. In particular:
Will do exactly what you’re asking for, recursively for the current working directory. Dropping the
-only
on the third argument will make it also transform characters that would be interpreted by the shell (and thus normally need escaped on the command line) into safe equivalents (usually_
).