Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save baybatu/888f614e58b562a9ea0701e2450ca9b4 to your computer and use it in GitHub Desktop.
Save baybatu/888f614e58b562a9ea0701e2450ca9b4 to your computer and use it in GitHub Desktop.
Process files by their last modified dates in Groovy
// 'delete' is a process example
public void deleteOldFiles(File path) {
long startOfDay = new Date().clearTime().time
path.eachFile { file ->
if (file.lastModified() < startOfDay) {
file.delete()
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment