Skip to content

Instantly share code, notes, and snippets.

@sagrawal31
Created April 28, 2017 15:24
Show Gist options
  • Save sagrawal31/c4090e7d3268affd053cc11fb24ae5ce to your computer and use it in GitHub Desktop.
Save sagrawal31/c4090e7d3268affd053cc11fb24ae5ce to your computer and use it in GitHub Desktop.
A Groovy code to recuse every file (of specific type) in a directory
import groovy.io.FileType
File fooDirectory = new File("/some-path-to-the-parent-directory")
// Recurse only *.html file (for example)
def reportNamePattern = ~/.*\.html/
fooDirectory.eachFileMatch(FileType.FILES, reportNamePattern) { File myFile ->
// Use myFile as you want
println myFile.name
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment