Skip to content

Instantly share code, notes, and snippets.

@yangxing-star
Last active August 29, 2015 13:57
Show Gist options
  • Save yangxing-star/9596682 to your computer and use it in GitHub Desktop.
Save yangxing-star/9596682 to your computer and use it in GitHub Desktop.
拷贝文件
def cp_files
dirs=Dir.glob('/home/ubuntu/shou65/public/uploads/media/*')
dirs.each do |dir|
src_dir = dir.split("/").last
mv_base_dir = "/data/tmp/uploads/media/#{src_dir}"
Dir.mkdir(mv_base_dir) unless Dir.exist?(mv_base_dir)
Dir.glob("#{dir}/*").each do |file|
FileUtils.cp file, mv_base_dir
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment