LoginSignup
47
43

More than 5 years have passed since last update.

Macの濁点ファイルをなんとかする

Posted at

Macで作った『ほげほげ.txt』をLinuxに転送すると、、

ほけ゛ほけ゛.txt

みたいに、濁点が1文字として扱われ、おかしなファイル名になっちゃう。

convmvで変換して解決

既にLinuxに転送してしまったファイルは、Linux上でなんとかしたほうが手っ取り早い。
例えば、Debian/Ubuntuならaptでconvmvをインストールできる。

$ sudo apt-get install convmv

カレントディレクトリのファイル名全部を変換したい場合はこんな感じ

$ convmv -r -f utf8 --nfd -t utf8 --nfc * --notest

--notestのオプションを外せば、実行結果の確認だけできる(ファイルへの反映は無し)


rsyncで転送時になんとかする

Macから転送する際にファイル名をなんとかする方法は、rsyncのiconvオプションを使うこと。
最初から用意されてるrsyncではiconvのオプションが上手く使えないので、Homebrewでインストールする。

$ brew tap homebrew/dupes
$ brew install libiconv
$ brew install rsync

rsyncのバージョンを確認

$ /usr/local/bin/rsync --version
rsync  version 3.0.9  protocol version 30

~/tmpに用意した『ほげほげ.txt』を example.comの~/tmpにファイル名の文字コードを直しつつ転送する例

$ /usr/local/bin/rsync -arvz --delete --iconv=UTF8-MAC,UTF-8 -e ssh ~/tmp/ほけ<3099>ほけ<3099>.txt example.com:~/tmp
47
43
1

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
47
43