#!/bin/sh
# CREATE DATE: 2007/11/26
# CREATE BY REVIVAL
#######################################################################


_DEBUG=1

CONVERT_TO=utf-8
CONVERT_FROM=euc-kr
#######################################################################

if [ "$1" = "" ]; then
	echo "ex> $0 <src_path> <dest_dir>"
	exit;
else
	SrcDir=$1
	FileList=`ls $SrcDir`
fi;

if [ "$2" = "" ]; then
	DestDir="dest.utf8"
else
	DestDir=$2
fi;

if [ ! -d $DestDir ]; then
	mkdir -p $DestDir
fi;

if [ "$_DEBUG" = "1" ]; then
echo ""
echo "File List '$1'"
echo $FileList
echo "Dest PATH: $DestDir"
fi;

#exit;
#######################################################################
echo "Start Convert $CONVERT_TO from $CONVERT_FROM"

for F in $FileList; do
	if [ "$_DEBUG" = "1" ]; then
		echo "convert $CONVERT_FROM -> $CONVERT_TO : $F"
	fi;

	cat $SrcDir/$F | iconv -f $CONVERT_FROM -t $CONVERT_TO > $DestDir/$F
done
