Return to Snippet

Revision: 2134
at January 3, 2007 00:54 by hansamann


Initial Code
def c
c = {println "Dir ${it.canonicalPath}"; it.eachDir(c); it.eachFile{println "File ${it.canonicalPath}"; it.delete()}}
c new File("test")

Initial URL


Initial Description
This (almost) one-liner cascades into all subdirectories and deletes the files first, then the directories. Makes deleting a directory really easy. This was originally posted by John Wilson into the Groovy user list.

Initial Title
Deleting all files and subdirectories

Initial Tags
file, directory

Initial Language
Groovy