Javascript: Gulp replace https://www.npmjs.com/package/gulp-replace
var replace = require('gulp-replace');
gulp.task('default', function () {
var index = 0;
return gulp.src('*.txt')
.pipe(replace(
/^/,
function () {
return '---\n' +
'id: ' + (++index) + '\n' +
'---';
}
))
.pipe(gulp.dest('./dest'));
});