用attrib进行修改属性

您所在的位置:网站首页 命令提示符下载文件夹怎么设置 用attrib进行修改属性

用attrib进行修改属性

2024-07-13 22:14:22| 来源: 网络整理| 查看: 265

用attrib进行修改属性

用attrib进行修改属性

attrib 0

Windows offers a wide variety of tools that you can access using your command prompt window including the “attrib” tool which is designed to help you search for files by location and name then view and modify their file attributes.

Windows提供了多种工具,您可以使用命令提示符窗口访问这些工具,其中包括“ attrib”工具,该工具旨在帮助您按位置和名称搜索文件,然后查看和修改其文件属性。

您可以使用哪些属性? (What Attributes Can You Use?)

Now that you have your elevated command prompt window open, you will need to know what types of attributes you can edit using the “attrib” tool. There are two main types of attributes, “basic” and “extended.”

现在您已经打开了提升的命令提示符窗口,您将需要知道可以使用“ attrib”工具编辑哪些类型的属性。 属性有两种主要类型,“基本”和“扩展”。

Basic Attribute Switches (R, H, A, S)

基本属性开关(R,H,A,S)

R – This command will assign the “Read-Only” attribute to your selected files or folders.

R –此命令将“只读”属性分配给您选择的文件或文件夹。 H – This command will assign the “Hidden” attribute to your selected files or folders.

H –此命令将“隐藏”属性分配给您选择的文件或文件夹。 A – This command will prepare your selected files or folders for “Archiving.”

A –此命令将为“存档”准备选定的文件或文件夹。 S – This command will change your selected files or folders by assigning the “System” attribute.

S –此命令将通过分配“系统”属性来更改您选择的文件或文件夹。 “属性”语法 (“Attrib” Syntax)

You will need to know the proper syntax to use for the “attrib” tool before you get started.

在开始之前,您将需要知道用于“ attrib”工具的正确语法。

ATTRIB [+ attribute | - attribute] [pathname] [/S [/D]] ATTRIB [+ attribute | - attribute] [pathname] [/S [/D]]

In this syntax, you will need to know what the different switches and parameters represent.

使用这种语法,您将需要知道不同的开关和参数代表什么。

The + and – indicate whether you will activate or deactivate the attribute specified.

+和–指示您将激活还是停用指定的属性。 The attributes you can use are those explained above.

可以使用的属性如上所述。 The “/S” signifies that you want to search the entire path specified including subfolders for a particular file.

“ / S”表示您要搜索指定的整个路径,包括特定文件的子文件夹。 The “/D” signifies that you want to include any process folders as well.

“ / D”表示您还希望包括所有过程文件夹。 The pathname indicates the location of your target folder or file. The proper syntax for path files is shown below.

路径名指示目标文件夹或文件的位置。 路径文件的正确语法如下所示。 Drive and/or filename - C:\*.* OR C:\Users\Owner\Desktop\samplefile.txt

If you decide not to specify any of the attributes listed above, the files or folders will revert to their current attribute settings.

如果您决定不指定上面列出的任何属性,则文件或文件夹将恢复为其当前的属性设置。

让我们练习 (Let’s Practice)

Now that you know the types of attributes you can use and the syntax you need to use, let’s practice some scenarios. Open the start menu in Windows 7 and 10 or open the search function in Windows 8 and search for CMD. Next, right-click on it and then press “Run as administrator.” While you don’t need to open an elevated command prompt window, it will help you to avoid any confirmation dialog boxes.

现在您已经知道可以使用的属性类型和需要使用的语法,让我们练习一些方案。 在Windows 7和10中打开开始菜单,或在Windows 8中打开搜索功能并搜索CMD。 接下来,右键单击它,然后按“以管理员身份运行”。 虽然您不需要打开提升的命令提示符窗口,但它将帮助您避免出现任何确认对话框。

attrib 1

Scenario 1 – Clear “Hidden and System” attributes with a single command to make your files or folders normal.

方案1 –使用单个命令清除“隐藏和系统”属性,以使文件或文件夹正常。

For this example, we will first create a file in your “Documents” directory called “sample.txt.” First, open up the directory and right-click somewhere in the window, move your mouse to the “New” section, click on “Text File,” and name the document “sample.”

对于此示例,我们将首先在您的“文档”目录中创建一个名为“ sample.txt”的文件。 首先,打开目录并右键单击窗口中的某个位置,将鼠标移至“新建”部分,单击“文本文件”,然后将文档命名为“ sample”。

attrib 2

Now go to your CMD window. We will change the file’s properties so that it is both a system file, and hidden. Do this by entering the following command.

现在转到您的CMD窗口。 我们将更改文件的属性,以使其既是系统文件又是隐藏文件。 通过输入以下命令来执行此操作。

attrib +h +s C:\Users\Martin\Documents\sample.txt attrib +h +s C:\Users\Martin\Documents\sample.txt

Remember to substitute the “Martin” section of the path parameter with your computer’s username.

切记用计算机的用户名替换path参数的“ Martin ”部分。

attrib 3

Once you have done this, you will notice that the file has disappeared from your documents folder. Now that we want to remove the System and Hidden file attributes from “sample.txt,” we will need to use the following simple command.

完成此操作后,您将注意到该文件已从文档文件夹中消失。 现在我们要从“ sample.txt”中删除“系统”和“隐藏”文件属性,我们将需要使用以下简单命令。

attrib –h –s C:\Users\Martin\Documents\sample.txt attrib 4

Note that if you try to enter the file name without a path, you will receive an error. You must remember to add the entire path to your command. Now, if you go back to your “Documents” directory, you will see the file in the list.

请注意,如果您尝试输入不带路径的文件名,则会收到错误消息。 您必须记住将整个路径添加到命令中。 现在,如果您返回“文档”目录,您将在列表中看到该文件。

Scenario 2 – Make all text files in your “Downloads” folder read-only system files.

方案2 –将“下载”文件夹中的所有文本文件设置为只读系统文件。

Now we will create a few sample text files in the “Downloads” directory and we will edit them using the “attrib” tool so that they all become read-only system files.

现在,我们将在“下载”目录中创建一些示例文本文件,并使用“ attrib”工具对其进行编辑,以使它们全部成为只读系统文件。

attrib 6

Once you have your sample text files created, it is time to use CMD to write a command that will change the attributes of all text files in a specified directory to “Read-Only and System.” For this, we will need to use wildcards to select all the text files. You can do this by using the command below. Remember to substitute the “Martin” section with your computer’s username.

创建示例文本文件后,就可以使用CMD编写命令,将指定目录中所有文本文件的属性更改为“只读和系统”。 为此,我们将需要使用通配符来选择所有文本文件。 您可以使用以下命令来执行此操作。 切记用计算机的用户名替换“ Martin ”部分。

attrib +r +s C:\Users\Martin\Downloads\*.txt attrib +r +s C:\Users\Martin\Downloads\*.txt attrib 7

Now you can open your downloads folder, right-click on one of the text files and then select properties. You will note that the file attributes have been changed.  To remove these settings simply use the same command, but replace the plus signs with minus signs.

现在,您可以打开下载文件夹,右键单击其中一个文本文件,然后选择属性。 您将注意到文件属性已更改。 要删除这些设置,只需使用同一命令,但用减号替换加号即可。

attrib -r -s C:\Users\Martin\Downloads\*.txt

Scenario 3 – Prepare a file located on your desktop for archiving.

方案3 –准备桌面上的文件进行归档。

Let’s start by creating a sample text file on the desktop. Now, navigate to your CMD window and enter the following string to prepare the selected file for archiving.

让我们从在桌面上创建示例文本文件开始。 现在,导航到CMD窗口并输入以下字符串以准备要归档的所选文件。

attrib +a C:\Users\Martin\Desktop\sample.txt attrib +a C:\Users\Martin\Desktop\sample.txt 属性8

Scenario 4 – Hide an entire Directory/Folder on your desktop.

方案4 –在桌面上隐藏整个目录/文件夹。

Let’s say for example, you have sensitive data in a folder on your desktop called “Private,” and you want to hide it along with all its files and subfolders. It is important to note that when you are working with directory attributes, you cannot use wildcards such as “? and *.” You will need to be explicit in your file path. First, you need to create a folder on your desktop and put a few files in it. Once you have done that, navigate to your CMD window and enter the following command.

例如,假设您的桌面上有一个名为“私有”的文件夹中有敏感数据,并且您希望将其连同所有文件和子文件夹一起隐藏。 重要的是要注意,在使用目录属性时,不能使用通配符,例如“?”。 和*。” 您需要在文件路径中明确显示。 首先,您需要在桌面上创建一个文件夹,并在其中放置一些文件。 完成此操作后,导航至CMD窗口并输入以下命令。

attrib +h C:\Users\Martin\Desktop\Private attrib 9

Once you press “Enter,” the entire folder will disappear since it will be hidden.

一旦按下“ Enter”,整个文件夹将消失,因为它将被隐藏。

attrib 10

Now you can play with some of the other settings to make changes to any file attributes on your computer.

现在,您可以使用其他一些设置来更改计算机上的任何文件属性。

翻译自: https://www.howtogeek.com/205910/how-to-change-file-attributes-with-attrib-from-the-windows-command-prompt/

用attrib进行修改属性



【本文地址】

公司简介

联系我们

今日新闻


点击排行

实验室常用的仪器、试剂和
说到实验室常用到的东西,主要就分为仪器、试剂和耗
不用再找了,全球10大实验
01、赛默飞世尔科技(热电)Thermo Fisher Scientif
三代水柜的量产巅峰T-72坦
作者:寞寒最近,西边闹腾挺大,本来小寞以为忙完这
通风柜跟实验室通风系统有
说到通风柜跟实验室通风,不少人都纠结二者到底是不
集消毒杀菌、烘干收纳为一
厨房是家里细菌较多的地方,潮湿的环境、没有完全密
实验室设备之全钢实验台如
全钢实验台是实验室家具中较为重要的家具之一,很多

推荐新闻


图片新闻

实验室药品柜的特性有哪些
实验室药品柜是实验室家具的重要组成部分之一,主要
小学科学实验中有哪些教学
计算机 计算器 一般 打孔器 打气筒 仪器车 显微镜
实验室各种仪器原理动图讲
1.紫外分光光谱UV分析原理:吸收紫外光能量,引起分
高中化学常见仪器及实验装
1、可加热仪器:2、计量仪器:(1)仪器A的名称:量
微生物操作主要设备和器具
今天盘点一下微生物操作主要设备和器具,别嫌我啰嗦
浅谈通风柜使用基本常识
 众所周知,通风柜功能中最主要的就是排气功能。在

专题文章

    CopyRight 2018-2019 实验室设备网 版权所有 win10的实时保护怎么永久关闭