A
A
Alexey2017-10-20 03:34:56
gulp.js
Alexey, 2017-10-20 03:34:56

Gulp rename - how to rename all files and folders in order?

Project structure:
59e9433800614766775493.png
Config:

var gulp = require('gulp');
var imageResize = require('gulp-image-resize');
var rename = require('gulp-rename');
 
var resizeImageTasks = [];

[100,300].forEach(function(size) {
  var resizeImageTask = 'resize_' + size;
  gulp.task(resizeImageTask, function() {
    return gulp.src('src/**/*.{jpg,png,tiff}')
      .pipe(imageResize({
         width:  size,
         height: size,
         upscale: false
       }))
      .pipe(gulp.dest('dist/' + size + '/'));
  });
  resizeImageTasks.push(resizeImageTask);
});

gulp.task('resize_all', resizeImageTasks);

I take all the pictures from all the folders and resize them. You need to rename all folders and files in order, nested too. Like gulp-rename can, but how?
What I get now as an output:
59e9438577544332742355.png
What I need to get:
59e9439a3757f873188565.png
Thank you.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question