From: "Alex C." Date: 2012-07-04T18:22:41+09:00 Subject: Re: Copying Files Jan E. wrote in post #1067354: > Alex C. wrote in post #1067346: >> Ryan Davis wrote in post #1067277: >>> You want to `ri Enumerable.reject` >> >> How do I use that? I can't find any examples > > You use it to reject all elements from an Enumerable for which the block > is true (to be more exact: not nil or false). > > As an example: > > numbers = 1..10 > # get even numbers by rejecting all odd numbers > even = numbers.reject {|num| num.odd?} > p even > > In your case you want to reject all files in a certain folder, so you > might check if the current file path begins with the folder path: > > > ignore_folder = 'C:/folder/ignore' > copy_files = Dir["#{original_path}/**/*.*"].reject do |file_path| > file_path.start_with? ignore_folder > end > > > However, this is not a perfect solution, because it will do an exact > string comparison rather than actually compare the paths. But it should > work for a small script. What needs to be changed with the following? require 'fileutils' original_path, target_path = 'D:/Stuff/Ruby/', 'C:/new' ignore_folder = 'D:\Stuff\Ruby\2' copy_files = Dir["#{original_path}/**/*.*"].reject do |file_path| file_path.start_with? ignore_folder end Many thanks for your help once again -- Posted via http://www.ruby-forum.com/.