Grunt - 删除具有特定文件扩展名的子目录中的所有文件和文件 [英] Grunt - delete all files and files in sub-directories with specific file extension

查看:103
本文介绍了Grunt - 删除具有特定文件扩展名的子目录中的所有文件和文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用Grunt.js删除目录中所有具有特定文件扩展名的文件及其所有子目录,我想我可能需要一个模块才能这样做?我看过干净,但似乎是删除整个目录,而不是具体的文件。



我的目录看起来像:




  • build / img /

  • build / img / ico

  • build / img / li>


以及我想要删除的文件扩展名是:

.png〜 .gif〜 .jpg扩展名



任何想法? 可以配置 grunt-contrib-clean 任务删除这些文件:

  clean :{
yourTarget:{
src:[build / img / ** / *。png〜,
build / img / ** / *。gif〜,
build / img / ** / *。jpg〜

}
}

请参阅文档的本节以获取 ** * 以及其他符合条件的模式。


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?

解决方案

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.

这篇关于Grunt - 删除具有特定文件扩展名的子目录中的所有文件和文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆