gulp工具rename

时间:2021-02-26 15:36:50

gulp 对文件批量重命名

gulp-rename重命名

 var gulp = require('gulp');
var rename = require("gulp-rename");
// rename via function
gulp.task('name', function() {
return gulp.src('./dist/**/*')
.pipe(rename(function(path) {
console.log(path)
var name = new Date().getTime();
path.basename = name;
}))
.pipe(gulp.dest('rename/'))
})
// rename via hash
gulp.task('name2', function() {
return gulp.src('./dist/**/*')
.pipe(rename({
dirname: "main",
basename: "dong",
prefix: "",
suffix: "",
extname: ""
}))
.pipe(gulp.dest('rename/'))
})