title: iconv any encoding to UTF-8
body: <p>I am trying to point iconv to a directory and all files will be converted UTF-8 regardless of the current encoding</p>
  
  <p>I am using this script but you have to specify what encoding you are going FROM. How can I make it autdetect the current encoding?</p>
  
  <p>dir_iconv.sh</p>
  
  <pre class="lang-sh prettyprint-override"><code>#!/bin/bash
  
  ICONVBIN='/usr/bin/iconv' # path to iconv binary
  
  if [ $# -lt 3 ]
  then
    echo "$0 dir from_charset to_charset"
    exit
  fi
  
  for f in $1/*
  do
    if test -f $f
    then
      echo -e "\nConverting $f"
      /bin/mv $f $f.old
      $ICONVBIN -f $2 -t $3 $f.old &gt; $f
    else
      echo -e "\nSkipping $f - not a regular file";
    fi
  done
  </code></pre>
  
  <p>terminal line</p>
  
  <pre><code>sudo convert/dir_iconv.sh convert/books CURRENT_ENCODING utf8
  </code></pre>