Command disabled: backlink

Removing accents from filenames in a directory tree

The following shell script can be used to remove accents from filenames in a directory and all subdirectories.

#!/bin/bash
 
function dodir() {
    pushd "$1" >> /dev/null
    for x in *; do
        trans=`echo "$x" | tr "éáóüűúöóíÉÁÓÜŰÚÖÓÍ" "eaouuuooiEAOUUUOOI" | tr -c "[:alnum:]!@#$%^&_,' ()[].\n-" "#"`
        if [ "$trans" != "$x" ]; then
            echo "must rename $x to $trans"
            mv "$x" "$trans"
            if [ -d "$trans" ]; then
                dodir "$trans"
            fi
        else
            if [ -d "$x" ]; then
                dodir "$x"
            fi
        fi
    done
    popd >> /dev/null
};
 
dodir "$1"

Linkbacks

Use the following URL for manually sending trackbacks: http://rigo.info/lib/plugins/linkback/exe/trackback.php/en:blog:removing_accents_from_filenames_in_a_directory_tree
en/blog/removing_accents_from_filenames_in_a_directory_tree.txt · Utolsó módosítás: 2009-04-14 00:00 (külső szerkesztés)
CC Attribution-Noncommercial-Share Alike 4.0 International
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0