I can think of two solutions:
Add an option for
base
to yourgulp.src
like so:gulp.src([...files...], {base: './'}).pipe(...)...
This will tell gulp to preserve the entire relative path. Then pass
'./'
intogulp.dest()
to overwrite the original files. (Note: this is untested, you should make sure you have a backup in case it doesn't work.)Use functions. Gulp's just JavaScript, so you can do this:
[...files...].forEach(function(file) { var path = require('path'); gulp.src(file).pipe(rename(...)).pipe(gulp.dest(path.dirname(file))); }
If you need to run these asynchronously, the first will be much easier, as you'll need to use something like
event-stream.merge
and map the streams into an array. It would look likevar es = require('event-stream'); ... var streams = [...files...].map(function(file) { // the same function from above, with a return return gulp.src(file) ... }; return es.merge.apply(es, streams);