Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Copy To A Target Directory And Filter Files

DZone's Guide to

Copy To A Target Directory And Filter Files

·
Free Resource
# 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 DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

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

X

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

{{ parent.tldr }}

{{ parent.urlSource.name }}