Thursday, September 2, 2010

bash script to convert encoding of all files in a directory

The following bash script calls iconv on each text file in the input directory and converts them from shift-jis (sjis) to Unicode UTF-8 (utf-8).


#! /bin/bash

inputDir="danu-summaries"
outputDir="danu"

for file in ../$inputDir/*; do
    if [ -f $file ]; then
fname=`echo "$file" | cut -d '/' -f3`
echo $fname
iconv -f sjis -t utf-8 ../$inputDir/$fname > ./$outputDir/$fname
    fi
done

No comments:

Post a Comment

Continuously monitor GPU usage

 For nvidia GPUs do the follwing: nvidia-smi -l 1