[macOS General] 名前が日本語のファイルを Mac で rsync する
grunt-rsync で Terminal.app 上の日本語表示が文字化け調べました。
が、もろもろインストール前後に確認しなかったので(後述)、ただのメモ。
[markdown]
## homebrew/dupes/rsync をインストール
対象は、iTunes のファイルで日本語が含まれる。
ファイル名に日本語を付けることがなかったので、今まで意識せず。
rsync のバージョンを上げ、`–iconv` オプションを使うと良いらしい。
> * [UTF-8-MACとは何か?〜Jekyllのカテゴリ(タグ)ページで濁点を含むページが表示されない〜](http://meganii.com/blog/2014/11/29/jekyll-tags-unread-because-of-utf-8-mac/)
> * [カテゴリー名に濁点を含んだ日本語が使えない問題を解決する(Rsyncのiconvオプションを使う) – gam0022.net](http://gam0022.net/blog/2012/08/11/use-rsync-iconv-option/)
Mac OS X Yosemite に標準で入っているバージョンは 2.6.9。
“`prettyprinted
% which rsync
/usr/bin/rsync
% rsync –version
rsync version 2.6.9 protocol version 29
Copyright (C) 1996-2006 by Andrew Tridgell, Wayne Davison, and others.
Capabilities: 64-bit files, socketpairs, hard links, symlinks, batchfiles,
inplace, IPv6, 64-bit system inums, 64-bit internal inums
rsync comes with ABSOLUTELY NO WARRANTY. This is free software, and you
are welcome to redistribute it under certain conditions. See the GNU
General Public Licence for details.
“`
[Homebrew/homebrew-dupes](https://github.com/Homebrew/homebrew-dupes) でインストールする。
“`prettyprinted
% brew install homebrew/dupes/rsync
“`
ログインし直すと version 3.1.1 に。
“`prettyprinted
% which rsync
/usr/local/bin/rsync
% rsync –version
rsync version 3.1.1 protocol version 31
Copyright (C) 1996-2014 by Andrew Tridgell, Wayne Davison, and others.
Web site: http://rsync.samba.org/
Capabilities:
64-bit files, 64-bit inums, 64-bit timestamps, 64-bit long ints,
socketpairs, hardlinks, symlinks, IPv6, batchfiles, inplace,
append, ACLs, xattrs, iconv, symtimes, no prealloc, file-flags
rsync comes with ABSOLUTELY NO WARRANTY. This is free software, and you
are welcome to redistribute it under certain conditions. See the GNU
General Public Licence for details.
“`
どうも libiconv も必要らしいのでインストールする。
“`prettyprinted
% brew install homebrew/dupes/libiconv
“`
## 実行
“`prettyprinted
% grunt rsync:musicDryrun
Running “rsync:musicDryrun” (rsync) task
rsyncing ~/Music/ >>> /Volumes/LaCieHD1TB/Music/
sending incremental file list
:
iTunes/iTunes Media/Music/椎名林檎/無罪モラトリアム/10 警告.m4a
iTunes/iTunes Media/Music/椎名林檎/無罪モラトリアム/11 モルヒネ.m4a
sent 862,312 bytes received 39,015 bytes 600,884.67 bytes/sec
total size is 440,557,261,134 speedup is 488,787.38 (DRY RUN)
Shell command was: rsync ~/Music/ /Volumes/LaCieHD1TB/Music/ –recursive –delete –dry-run –verbose –exclude=.DS_Store –size-only
OK
Done, without errors.
“`
`–iconv` オプションを付けずに試して解決しているように見える。
このケースについては、libiconv をインストールしたから解決しただけのような気がする。
他の OS に向けて rsync する場合は、`–iconv` オプションを使い、ファイル名を UTF-8-MAC から UTF-8 に変換するって事だと思います。
“`prettyprinted
% rsync –iconv=UTF-8-MAC,UTF-8
“`
## 補遺
[grunt-rsync](https://github.com/jedrichards/grunt-rsync) で `–iconv` オプションを付けるには、`args:` をつかうよう。
“`javascript
rsync: {
options: {
args: [“–verbose”],
exclude: [“.git*”,”*.scss”,”node_modules”],
recursive: true
},
“`
> * [grunt-rsync で開発サーバへ deploy する | deadwood](https://www.d-wood.com/blog/2014/08/26_6710.html)
[/markdown]