Folder comparison





6
Date Submitted Fri. Feb. 9th, 2007 7:36 AM
Revision 1 of 1
Helper glaforge
Tags groovy
Comments 0 comments
Recursively iterate over folders and files to check for differences.

def firstPath  = "C:\\carrefour-infraws2"
def secondPath = "C:\\carrefour-infraws"

def firstPathFile  = new File(firstPath)
def secondPathFile = new File(secondPath)

def corresp = [
    (-1): " + new    ",
     (0): "          ",
    (+1): " + old    "]

firstPathFile.eachFileRecurse { file ->

    def absolutePath = file.absolutePath
    if (!absolutePath.contains("CVS")) {
        if (!file.isDirectory()) {
            def lastModified = new Date(file.lastModified())
            def secondFile = new File(secondPath + absolutePath[firstPath.size()..-1])
            println "${corresp[secondFile.lastModified() <=> file.lastModified()]} \t $absolutePath"
        } else {
            println "\n=== $absolutePath =============================="
        }
    }
}
 

Guillaume Laforge

glaforge.free.fr/blog/groovy

Comments

There are currently no comments for this snippet.

Voting