The MS-DOS command attrib
changes the attributes of a single file. How can I use it to change the attributes of a group of files?
views:
19answers:
3This is the info you need
Displays or changes file attributes. ATTRIB [+R | -R] [+A | -A ] [+S | -S] [+H | -H] [drive:][path][filename] [/S [/D]] + Sets an attribute. - Clears an attribute. R Read-only file attribute. A Archive file attribute. S System file attribute. H Hidden file attribute. [drive:][path][filename] Specifies a file or files for attrib to process. /S Processes matching files in the current folder and all subfolders. /D Processes folders as well.
By using the '/s' parameter will do it for matching files for example
attrib -rhsa *.txt /s
That will remove the read, hidden, system and archive attributes from ALL files ending with '.txt'.
I believe it would be using the wildcard character. Such as:
attrib +r * --This sets all files with that attribute
or
attrib +r *.doc --sets files ending in .doc with that attribute
Or something of the sort, whichever fits your needs. However, if there are hidden files in the result, those won't be updated. At least they weren't on my computer.
EDIT: Use the previous answer for the other attributes that can be set. I only listed an example, not a complete list. www.computerhope.com is a good site for dos commands.
Where is this group of files?
You can use the FOR
command for greater flexibility:
FOR /R "[directory]" %%f IN ([filetype]) DO (
attrib [opts] "%%f"
)
Where [directory]
is a directory (like %CD%
or C:\Users\me\Desktop
), [filetype]
is a filter (like *.txt
or log?.log
) and [opts]
is the option set you will use to call attrib
.