Anicky of Micropole Lyon Pole web
3/26/2016 - 11:07 PM

Corrige les encodages windows sur UNIX

Corrige les encodages windows sur UNIX

#!/bin/sh
encodeFrom='ISO-8859-1'
encodeTo='UTF-8'

# Add "-not \( -path ./PATH -prune \)" to ignore specific folder
for f in `find . -type f`
do
  file -i $f | egrep -e $encodeFrom | egrep -v "charset=binary"
  if [ $? = 0 ] 
  then
    mv $f $f.save
    iconv -f $encodeFrom -t $encodeTo $f.save -o $f
    #rm $f.save
  fi
done