LoginSignup
3
5

More than 5 years have passed since last update.

Macの複数フォルダを一気にリソースフォーク付きでzipする

Last updated at Posted at 2015-03-03

ワンライナー。
find . -mindepth 1 -maxdepth 1 -type d -exec ditto -c -k --sequesterRsrc --keepParent "{}" "{}.zip" \;

解説。
① ditto はMacの固有コマンドで、ファイルのコピーやアーカイブの作成・展開などをするコマンド。
右クリックの「圧縮」でzipするのと同じ操作をコマンドでやるならば

ditto -c -k --sequesterRsrc --keepParent src_directory archive.zip

This manual page is for Mac OS X version 10.9

② findコマンドは -exec オプションで、後ろに書いたコマンドを実行できる。検索結果は {} に渡る。
find . -mindepth 1 -maxdepth 1 -type d -exec echo {} \;

この2つを組み合わせる。


-exec は 複数書いてもいいので、zipした後元フォルダを削除するならば、

find . -mindepth 1 -maxdepth 1 -type d -exec ditto -c -k --sequesterRsrc --keepParent "{}" "{}.zip" \; -exec rm -rf "{}" \;
という風にすればできる。

3
5
0

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
3
5