ruby复制文件夹到新的重命名的文件夹

require 'yaml'
require 'find'
require 'fileutils'

SOURCE_DIR = "/media/zn/工作1/开发/网站主题数据/themes/"
TARGET_DIR = "/media/zn/商品1/themes/"

site_themes = YAML.load_file("site_themes.yml")
site_themes.each do |theme|
   title = theme[0] 
   tag = theme[1]
   source_name = theme[3].gsub(/\/.*\//, '').sub(/\.zip/,'')
   new_name = "网站模板-" + title + tag.join(",")

   begin
     FileUtils.cp_r(SOURCE_DIR + source_name, TARGET_DIR + new_name)
   rescue
     puts source_name + "....error"
     next
   end
end 

 

上一篇:ggplot2|theme主题设置,详解绘图优化-“精雕细琢”-


下一篇:Eclipse设置风格