Search code examples
javascriptgulpcase-sensitive

Gulp: Copying files from A to B while keeping case-senstive folder-names


I want to create a gulp-task that takes files from all folders named "foldertocopy" and copies them to some output directory.

Imagine the following file-structure:

  • Root
    • js
      • foldertocopy
    • css
      • FOLDERTOCOPY

My gulp-task looks like this:

return gulp.src('./Root/**/foldertocopy/**/*.*')
    .pipe(gulp.dest('./Root2'));

The copying itself works perfect. But all copied folders are called "foldertocopy" (while some of them should be called "FOLDERTOCOPY").

How can I make sure the case is kept while copying?


Solution

  • the pattern in your gulp.src is glob style so in you can pass second parameter to the glup.src in which define the glob flag

    in your case i think this code should work

    return gulp.src('./Root/**/foldertocopy/**/*.*',{nocase:true})
               .pipe(gulp.dest('./Root2'));