Created
July 16, 2014 23:01
-
-
Save fatbigbright/c917d55fea63070123ee to your computer and use it in GitHub Desktop.
将sourceDir目录中与sameWithDir目录同名的文件拷贝到targetDir中
This file contains hidden or 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
require 'fileutils' | |
def cpSameFile(sourceDir, targetDir, sameWithDir) | |
Dir.foreach(sameWithDir) do |file| | |
puts file | |
filePath = sourceDir + "/" + file | |
targetPath = targetDir + "/" + file | |
if file == "." or file == ".." or File.directory?(file) | |
else | |
if File.exist?(filePath) | |
FileUtils.cp filePath, targetPath | |
end | |
end | |
end | |
end | |
cpSameFile(ARGV[0], ARGV[1], ARGV[2]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment