I need to search a directory structure for all files beginning with a period (don’t ask…) and change them from read-only to rw. I can identify those files with the first command, but how can I translate that into the 2nd command?
dir .*.* /s /a-D /ar
Now I want to take that output and run attrib +r. This is what I’ve gotten, but it isn’t working.
for /f %f in ('dir .*.* /s /a-D /ar') DO "ATTRIB +R" "%G"
I think I am close, but DOS batch commands have never worked as I expect them to (my problem, not DOS’s)
The reason it’s not working is because
attrib +rmakes the processed tokens read-only again and also because you use capital %G where you should use small letters.In Windows read-only files are different from Linux in ways that you either mark a file as read-only or not.
If it is not read-only it will use the properties found in the ACL for the folder/file.
Typically it will generate the file RW instead of Read-Only.
You can read more about it here:
http://msdn.microsoft.com/en-us/magazine/cc982153.aspx
So for your question:
(As I dont have any files or folders prefixed with . I cannot test and see if the above works, you may want to use %f instead of %g, depending on which token you want to use.)
The above will do
attrib -rwhich removes the read-only attribute.You may want to use double %% for batch-scripts that are to be executed as .bat, .cmd etc.
As stated in the
for /?help screen:Further more: