LoginSignup
79

More than 5 years have passed since last update.

【Mac】フォルダ内のファイルの文字コードを一括変換する

Last updated at Posted at 2013-12-04

nkfのインストール

Macにnkfがインストールされていない場合は、下記をまず実行する。

  1. http://sourceforge.jp/projects/nkf/ から最新のダウンロードファイルをDLする。(2013/12/4時点で2.1.3)

  2. 以下のコマンドを叩く

#もし/usr/local/srcが無い場合は作る
mv nkf-2.1.3.tar.gz /usr/local/src/
cd /usr/local/src/
sudo tar xvzf nkf-2.1.3.tar.gz
cd nkf-2.1.3
#makeがインストールされていない場合はXcodeのCommand Line Toolをインストール
sudo make
sudo make perl
sudo cp nkf /usr/local/bin/
cd NKF.mod
sudo perl Makefile.PL
sudo make
sudo make test
sudo make install
nkf --help

nkfコマンドで文字コード変更

#カレントディレクトリのファイル全てをSJISに変換
 nkf -s --overwrite ./*

  • -s:SJIS
  • -e:EUC
  • -w:UTF8

です。

参考

nkf インストール - El mar verde( http://d.hatena.ne.jp/elmarverde/20101108/p1 )

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
79