Linux – How to recursively rename files/folders to make their names Windows-friendly

batch-renamelinuxrename

I have a bunch of files on a Ubuntu box, which have various characters in their filenames that Windows doesn't accept (mostly ":" and "*", but possibly others).

What's the simplest way to get these all renamed and moved to a Windows machine? It's OK to replace these characters with something like "[colon]" and "[asterisk]".

Best Answer

Take a look at Glindra rename and detox.

Glindra file utilities can be installed on either Windows or Linux. Examples of cleaning up file names on Windows:

rena *.* -portable

rena *.* -safe
  • -safe
    Maps leading dashes (hyphens) to underscores.
    Collapses spaces.
    Maps problematic characters like *?:[]"<>|(){} to underscore.
  • -portable
    Performs the same cleanup operations as -safe, and additionally:
    Maps all 8-bit characters from the upper half of the Latin 1 alphabet to reasonable 7-bit fallback characters.
    Maps the single quote characters '`ยด to underscore.

Source: Fixing Unix/Linux/POSIX Filenames: Control Characters (such as Newline), Leading Dashes, and Other Problems

Related Question