0

I'm getting a file and moving it with gulp:

gulp.src('src/myfile.html')
.pipe(gulp.dest('dist'));

How can I rename the file too?

panthro
  • 22,779
  • 66
  • 183
  • 324
  • Possible duplicate of [Gulp - copy and rename a file](http://stackoverflow.com/questions/28593660/gulp-copy-and-rename-a-file) – Sven Schoenung Nov 09 '16 at 16:28

1 Answers1

1

Try https://www.npmjs.com/package/gulp-rename

// rename via string 
gulp.src("./src/main/text/hello.txt")
  .pipe(rename("main/text/ciao/goodbye.md"))
  .pipe(gulp.dest("./dist")); // ./dist/main/text/ciao/goodbye.md 


// rename via function 
gulp.src("./src/**/hello.txt")
  .pipe(rename(function (path) {
    path.dirname += "/ciao";
    path.basename += "-goodbye";
    path.extname = ".md"
  }))
  .pipe(gulp.dest("./dist")); // ./dist/main/text/ciao/hello-goodbye.md 
Mark Williams
  • 2,268
  • 1
  • 11
  • 14