Change attributes of a group of files in MS-DOS
The MS-DOS command attrib
changes the attributes of a s开发者_开发知识库ingle file. How can I use it to change the attributes of a group of files?
This 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'.
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
.
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.
精彩评论