Linux:Dateinamen bereinigen

Aus ITWiki
Zur Navigation springen Zur Suche springen

1 detox

The detox utility renames files to make them easier to work with. It removes spaces and other such annoyances. It'll also translate or cleanup Latin-1 (ISO 8859-1) characters encoded in 8-bit ASCII, Unicode characters encoded in UTF-8, and CGI escaped characters.

detox -rv files

2 mv/sed

mv 'file' $(echo 'file' | sed -e 's/[^A-Za-z0-9._-]/_/g')

3 convmv

convmv -r -f windows-1252 -t UTF-8 .
convmv -r -f ISO-8859-1 -t UTF-8 .
convmv -r -f cp-850 -t UTF-8 .

4 find/perl

find /path/to/files -type f -print0 | \
perl -n0e '$new = $_; if($new =~ s/[^[:ascii:]]/_/g) {
 print("Renaming $_ to $new\n"); rename($_, $new);

5 rename

rename 's/[^\x00-\x7F]//g' *
find . -exec rename 's/[^\x00-\x7F]//g' "{}" \;