I need to delete all files with a specific file extension in a directory and all of its sub-directories using Grunt.js and I guess I probably need a module to do so? I've looked at clean but that seems to be for deleting whole directories rather than specific files.
My directory looks like:
- build/img/
- build/img/ico
- build/img/logos
and the file extension I want to delete is:
Any file with the extension of .png~
, .gif~
or .jpg~
Any ideas?
go-oleg
You can configure the grunt-contrib-clean
task to remove those files like this:
clean : {
yourTarget : {
src : [ "build/img/**/*.png~",
"build/img/**/*.gif~",
"build/img/**/*.jpg~"
]
}
}
See this section of the docs for an explanation of **
, *
, and other globbing patterns.
Adam Simpson
来源:https://stackoverflow.com/questions/17223237/grunt-delete-all-files-and-files-in-sub-directories-with-specific-file-extensi