4

How can we remove readonly attribute from all files under a folder in Windows?

UPDATE: The question is more about how to remove readonly attribute using gulpfile

2

2 Answers 2

7

I figured out the answer:

To remove readonly attribute of all files under a directory recursively, we run the following command in windows Command line

attrib -r <dir-name>\*.* /s

Following gulp task removes readonly attribute of all files under

gulp.task('remove-readonly-attributes', function() {
    require("child_process").exec("attrib -r <dir-name>\*.* /s");
});
2
  • 1
    Always provide all callback when not returning a gulp stream: function(done) { require("child_process").exec("command", done); }
    – Gigo
    Oct 11, 2015 at 20:56
  • This seems to be the only solution that works for me on my Windows workstation
    – myTerminal
    Nov 14, 2016 at 13:56
2

I ended up solving this problem with gulp-chmod.

https://www.npmjs.com/package/gulp-chmod

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.