Created
June 21, 2013 09:34
-
-
Save tanaka51/5830074 to your computer and use it in GitHub Desktop.
find-cp png jpg -o ~/path/to/directory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'fileutils'; include FileUtils | |
require 'optparse' | |
dest_path = "" | |
noop = "" | |
opt = OptionParser.new | |
opt.on('-o VAL') {|v| dest_path = v } | |
opt.on('-d', '--dry-run') {|v| noop = v } | |
opt.on('-f', '--force') {|v| noop = !v } | |
noop ||= true | |
files = [] | |
opt.permute(ARGV).reduce(files){|fs, extension| fs << `find . -name "*.#{extension}"`.split } | |
files.flatten.each {|f| cp f, dest_path + '/' + f[1..-1].gsub('/', '_'), noop: noop, verbose: true } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ディレクトリ指定するのに
-o
ってオプションは何か違う気もした