Skip to content

Instantly share code, notes, and snippets.

@tamirko
Created August 13, 2014 12:47
Show Gist options
  • Save tamirko/e054504edd2c39515870 to your computer and use it in GitHub Desktop.
Save tamirko/e054504edd2c39515870 to your computer and use it in GitHub Desktop.
deleteDummyFiles custom command
"deleteDummyFiles" : { prefix, xFiles ->
def p = ~/$prefix.*\.txt/
def counter=0
def howManyfiles = xFiles.toInteger()
println "Deleting ${howManyfiles} .txt files '${prefix}*' in ${dummyFilesFolder} ..."
new File(dummyFilesFolder).eachFileMatch(p) {f ->
if ( counter < howManyfiles ) {
counter++
println "Deleting file #${counter} ${f.getName()} ..."
f.delete()
}
}
println "Done deleting all .txt files in ${dummyFilesFolder} "
return "Done"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment