Difference between revisions of "Fix broken Umlauts in Filenames"

From S23Wiki
Jump to: navigation, search
(Created page with "Not really optimized yet... [pre] #/bin/bash for d in * do if [ -d $d ]; then cd "$d" for i in * do #x=$(echo $i | sed 's/\xc2\x91\|\xc2\x92\|\xc2\xa0\|...")
 
 
Line 1: Line 1:
Not really optimized yet...
+
rename.sh:
  
 
[pre]
 
[pre]
#/bin/bash
+
for i in *
for d in *
+
 
   do
 
   do
   if [ -d $d ]; then
+
   x=$(echo $i | iconv -f utf8 -t ascii//TRANSLIT -c)
    cd "$d"
+
  if [ "$i" != "$x" ];
    for i in *
+
  then
    do
+
    echo "$i --TO-- $x"
      #x=$(echo $i | sed 's/\xc2\x91\|\xc2\x92\|\xc2\xa0\|\xe2\x80\x8e//g' | sed 's/ü/ue/g' | sed 's/[^a-z0-9_~\.-]/_/gi' )
+
    #mv "$i" "$x"
      x=$(echo $i | iconv -f utf8 -t ascii//TRANSLIT -c)
+
  fi
      echo "$x"
+
  if [ -d "$x" ]; then
      mv "$i" "$x"
+
     cd "$x"
     done
+
    echo "cd to $x"
 +
    /path/to/rename.sh
 
     cd ..
 
     cd ..
 
   fi
 
   fi
 
done
 
done
 
[/pre]
 
[/pre]

Latest revision as of 13:40, 15 May 2013

rename.sh:

[pre] for i in *

 do
 x=$(echo $i | iconv -f utf8 -t ascii//TRANSLIT -c)
 if [ "$i" != "$x" ];
 then
   echo "$i --TO-- $x"
   #mv "$i" "$x"
 fi
 if [ -d "$x" ]; then
   cd "$x"
   echo "cd to $x"
   /path/to/rename.sh
   cd ..
 fi

done [/pre]