Fork me on GitHub

gulp工具rename

gulp 对文件批量重命名

gulp-rename重命名

 1 var gulp = require('gulp');
 2 var rename = require("gulp-rename");
 3 // rename via function 
 4 gulp.task('name', function() {
 5   return gulp.src('./dist/**/*')
 6     .pipe(rename(function(path) {
 7       console.log(path)
 8       var name = new Date().getTime();
 9       path.basename = name;
10     }))
11     .pipe(gulp.dest('rename/'))
12 })
13 // rename via hash 
14 gulp.task('name2', function() {
15   return gulp.src('./dist/**/*')
16     .pipe(rename({
17         dirname: "main", 
18         basename: "dong",
19         prefix: "", 
20         suffix: "", 
21         extname: ""
22     }))
23     .pipe(gulp.dest('rename/'))
24 })

 

posted @ 2016-12-09 10:14  donglegend  阅读(465)  评论(0编辑  收藏  举报