Recursive copy excluding folders matching filter

Viewed 4601

I am trying to create a Rake method to copy all files from one location to another but exclude all folders that are SVN folders including their files.

This is the method in a module called Filesystem I started with, but can't figure out if it will work or what the missing code is. The module has the following require:

require "fileutils"

Method:

def FileSystem.CopyFilesWithoutSVN(source, target)
  # will copy files from source folder to target folder excluding .svn folders
  FileUtils.cp_r  Dir.glob( source ).reject{|entry| entry =~ missingCode }, target
end

So for example the source would be:

folderA
  folderB
    file1.cs
    file2.cs
    file3.cs
    file4.cs
    .svn
        fileA.base
        fileB.base
.svn
  fileC.base
  fileD.base
folderC 
    file5.cs

then the target would contain the following after the copy:

folderA
  folderB
    file1.cs
    file2.cs
    file3.cs
    file4.cs
folderC
    file5.cs  
4 Answers
Related