Skip to content

Instantly share code, notes, and snippets.

@tekei
Created September 24, 2012 00:04
Show Gist options
  • Select an option

  • Save tekei/3773504 to your computer and use it in GitHub Desktop.

Select an option

Save tekei/3773504 to your computer and use it in GitHub Desktop.
ifunboxの文字化け解消
#!/bin/bash
# macでフォーマットしたipodをWindowsに持ってきたときUnicodeの正規化により
# 困ったことになるのを解消
# Windows上で、cygwinとnkfが入っている環境を想定。
CMD_NKF=nkf32
CMD_AWK=gawk
IFS=$'\n'
#for filename in `/bin/ls -l | gawk '/^drwx------/{for(i=1; i<8; i++) $i=""; gsub(/^[ ]+/,"",$0); print;}'`
for filename in `find . -name "*" -print | sed 's:^./::'`
do
if [ "$filename" = "." ]; then
continue
fi
current_name=`echo "$filename" | $CMD_AWK -F'/' '{print $NF;}'`
newname=`echo "$current_name" | $CMD_NKF --ic=UTF8-MAC -w`
if [ "$current_name" != "$newname" ];
then
newname_prev=`echo "$filename" | $CMD_AWK -F'/' '{OFS="/";NF=NF-1;print;}' | $CMD_NKF --ic=UTF8-MAC -w`
if [ "$newname_prev" = "" ];
then
filename_all="$current_name"
newname_all="$newname"
else
filename_all="$newname_prev""/""$current_name"
newname_all="$newname_prev""/""$newname"
fi
echo "[""$filename_all""] → [""$newname_all""]"
mv "$filename_all" "$newname_all"
fi
done
@tekei

tekei commented Sep 24, 2012

Copy link
Copy Markdown
Author

以前、blog上で公開していたものと同じものです。
blog再構築により、blog上から削除したためこちらに記載しました。

@tekei

tekei commented Sep 24, 2012

Copy link
Copy Markdown
Author

以前、blog上で公開していたものと同じものです。
blog再構築により、blog上から削除したためこちらに記載しました。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment