Read only check and set with bat

September 25, 2011 at 10:40:04
Specs: Windows XP
How to check if some file is read only and if not to set like this:

if example.txt atrrib -r then set atrrib +r

See More: Read only check and set with bat

Report •

September 25, 2011 at 19:05:48
you would probably have to output the attrib into a file like this:

attrib "example.txt" > file.tmp

then for loop to get the attribute into a variable

for /f "tokens=1" %%A in (file.tmp) do set var=%%A

then evaluate the variable. If the variable is not equal to (neq) R, then attrib +R

if %var% neq R attrib +R example.txt

Report •
Related Solutions

Ask Question