Over a million developers have joined DZone.

Copy To A Target Directory And Filter Files

·
# not the best code around but worked for my usage,...
require 'fileutils'
target = "../custom_code/"
FileUtils.mkdir(target) unless File.exist?(target)

require "rake"
FileList['**/*.java'].each do |source|
  file_name = File.basename(source)
  target_dir = target + File.new(source).path.sub(file_name, '')
  makedirs target_dir 
  cp_r source, target_dir + file_name, :verbose => true
end

Topics:

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}