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:

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

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

{{ parent.tldr }}

{{ parent.urlSource.name }}