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
原文:https://www.cnblogs.com/znsongshu/p/11373920.html