在 MS-DOS 中更改一组文件的属性

发布于 2024-09-14 22:12:02 字数 62 浏览 9 评论 0原文

MS-DOS 命令attrib 更改单个文件的属性。如何使用它来更改一组文件的属性?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

挽手叙旧 2024-09-21 22:12:02

这是您需要的信息

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.

通过使用“/s”参数将为匹配文件执行此操作,例如

attrib -rhsa *.txt /s

将从所有以“.txt”结尾的文件中删除读取、隐藏、系统和存档属性。

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'.

天赋异禀 2024-09-21 22:12:02

这组文件在哪里?

您可以使用 FOR 命令获得更大的灵活性:

FOR /R "[directory]" %%f IN ([filetype]) DO (
attrib [opts] "%%f"
)

其中 [directory] 是目录(如 %CD%C:\ Users\me\Desktop),[filetype] 是一个过滤器(如 *.txtlog?.log),并且[opts] 是您将用于调用 attrib 的选项集。

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.

狼性发作 2024-09-21 22:12:02

我相信它将使用通配符。例如:

attrib +r * --这设置具有该属性的所有文件

attrib +r *.doc --设置具有该属性的以 .doc 结尾的文件

或类似的内容,以适合您的需求为准。但是,如果结果中有隐藏文件,这些文件将不会被更新。至少它们不在我的电脑上。

编辑:使用前面的答案来设置其他可以设置的属性。我只列出了一个示例,而不是完整列表。 www.computerhope.com 是一个了解 dos 命令的好站点。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文