Linuxなどでディレクトリをコピーする際に使うのがcpコマンドです。ごくごく基本的なコマンドなので使うのは簡単ですが、あまり融通が効かなかったりします。そのため、一旦コピーしてから別途ファイル操作を行うと言った人もいるのではないでしょうか。 そこで使ってみて欲しいのがcpy-cliです。cpコマンドをちょっと便利にしてくれるソフトウェアです。

cpy-cliの使い方

一例です。!を付けると除外対象になります。

$ cpy 'assets/*.gif' '!assets/css' data/

ヘルプです。リネームなどもできます。

$ cpy --help

  Copy files

  Usage
    $ cpy <source />... <destination>

  Options
    --no-overwrite       Don't overwrite the destination
    --parents            Preserve path structure
    --cwd=<dir>          Working directory for files
    --rename=<filename>  Rename all <source /> filenames to </filename><filename>

  <source /> can contain globs if quoted

  Examples
    Copy all .png files in src folder into dist except src/goat.png
    $ cpy 'src/*.png' '!src/goat.png' dist

    Copy all .html files inside src folder into dist and preserve path structure
    $ cpy '**/*.html' '../dist/' --cwd=src --parents

cpy-cliはnodeで作られており、ごくごく基本的な使い方としてはcpコマンドと変わりません。しかしパターンを用いることで少しだけ便利にしてくれます。意外とありそうでなかったソフトウェアと言えます。こういうコマンド拡張のようなソフトウェアは自分用として便利そうです。

cpy-cliはnode/JavaScript製のオープンソース・ソフトウェア(MIT)です。

sindresorhus/cpy-cli: Copy files