Computers Windows Internet

Windows attributes. ATTRIB command to change file attributes

If you opened a USB flash drive, and all the data on it disappeared, do not rush to panic! Most likely, the attributes of files and folders that were stored there were accidentally changed. We will tell you how to return the correct attributes in the article below!

As much as I work with computers, I am convinced that they like to give users a lot of inconvenience. Moreover, often all the "tricks" stem from our ignorance of any fundamentals or features of the system and its components ...

It happened this time too. I didn’t have time to start a new job, but already faced another computer "problem" :)

Files on the flash drive disappeared

They bring me a USB flash drive with which I need to reset the document. The flash drive opens, but there is nothing on it! Fortunately, I have already encountered a similar situation and even demonstrated a similar effect to students when I led a circle at school. But on unprepared colleagues, this event made not the most pleasant impression ...

I asked not to panic. Calling the properties of the flash drive and making sure that it is not empty (a certain percentage of the space on it was occupied by data), I opened it using file manager and saw in place all the files that were displayed as translucent - that is, hidden:

The whole "trouble" is that every file in Windows, in addition to the usual characteristics, such as name, extension or size, has a number of not entirely obvious properties. One of them is attributes. The attributes themselves are few, but they affect how the system works with files.

In our case, for example, the "system" and "hidden" attributes lead to the visual "disappearance" of the file from Explorer, if the "Show hidden files, folders" option is not active in the "Folder Properties" (Control Panel or the "View" menu of any folder) and disks "and the" Hide protected system files "checkbox is enabled, as is usually the default:


We figured out the reason, but how to return the files to normal attributes so that they can be seen in Explorer? The problem is that the "hidden" attribute is displayed in the File Properties, but it cannot be cleared because the checkbox is inactive.

If you have Total commander or another similar file manager, you can invoke the attribute editor from the "File" menu. However, in my opinion, it is more convenient to use the Command Line for these purposes! Press the key combination "WIN + R" on the keyboard, in the "Run" line enter "cmd" without quotes and press Enter. In the opened Console window, enter the "attrib" command of the form:

attrib -r -a -s -h(removing all basic attributes) H: \ *. *(path to folder and mask of file names, which selects the entire contents of the specified directory) / s / d(additional command keys to reset file attributes in folders and subfolders)


After executing the command, all files and folders on the USB flash drive should appear in their normal form, which is what we needed :) For those who care about not only the result, but also understanding where and what comes from, I propose to deal with the attributes in more detail.

Common file attributes

In total, Windows has historically had 4 main attributes that any files and partially folders can have:

  1. Read-only - R... Usually used to prevent editing of text files. One of the unconventional ways of using it is write protection of a flash drive (a read-only folder is created at the root), but viruses can bypass such protection.
  2. "Archival" (archived) - A... It is mainly needed only for backup programs to recognize which files are already included in the backup, and which ones have changed and must be replaced.
  3. "System" - S... This attribute usually marks system files that the user does not want to touch. Based on this, such files are not displayed in Explorer, unless the "Hide protected system files" option is disabled in the "View" tab in the "Folder options" section.
  4. Hidden - H... Allows you to hide any files and folders without the need to mark them as system. Similar to the previous attribute, it prevents displaying in Explorer if the "Show hidden files, folders and drives" setting is not enabled.

In addition, in recent Windows versions a number of other attributes have appeared that usually do not need to be changed, but which are worth knowing about:

  • "compressed" (C);
  • "encrypted" (E);
  • "indexed" (I);
  • "temporary" (T);
  • integrity attribute (V);
  • "without purification" (X).

Some of these attributes can be seen in the Properties of the file, and some are accessible only by the most file system and is not displayed anywhere:

Also, the file's timestamp is sometimes referred to as attributes, which includes three dates: creation, modification and first opening. The system usually displays only the modified date, but the rest of the timestamps can be seen in the same Properties:

Obviously, change the creation date of the file without third-party programs it is impossible, but to correct the date of the change, it is enough to make any edits to the file. The date will change automatically.

Viewing and Editing Attributes

About what file attributes are for, how they can be viewed and edited regular means we have already figured out the systems. Here I would like to consider ways of interacting with them through third-party programs.

As mentioned above, it is quite convenient to work with attributes in visual mode using file managers.

For example, in the popular Total Commander, to enable the display hidden files and folders, you need to go to the "View" - "Advanced settings" menu and at the bottom activate the "Show hidden / system files: on / off" option. Now that everything is visible, select the files from which you want to remove the attributes, go to the "Files" menu and click the "Change Attributes" item:


A pretty nice window will open, where in visual mode you can not only apply all the parameters of the standard ATTRIB command, but also change the file modification timestamp (unfortunately, you cannot change the creation label without special plugins).

Another popular file manager Free Commander has a similar window. Here, to enable the display of hidden files, you also need to go to the "View" menu, and from there to the "Show" submenu, where you can mark all the items. Editing the same attributes in this file manager is also in the "File" menu and is called "Attributes / timestamp":


The tool for editing attributes built into Free Commander even surpasses its counterpart in Total Commander in terms of functionality. First, it supports additional attributes compression. Secondly, it allows you to select files to edit by mask. And thirdly, it allows you to change all timestamps!

Well, for a snack, if you do not want to download a full-fledged file manager just for the sake of adjusting the attributes of some files, you can easily get by with highly specialized utilities. A good example is BulkFileChanger from renowned NirSoft developers:


Download the program from the link for 32-bit or 64-bit systems and the Russian.zip file. We extract the crack from the latter, throw it into the main archive of the program and we can run it. A window should appear in Russian, similar to the one in the screenshot above.

We just need to add files for processing to the list, select them and click the "Change time / attributes" button on the top panel. If you do everything correctly, the following window will open in front of you:


Here, as you can see, you can change absolutely any timestamps and all the main attributes of the files. Mark the boxes that need to be changed and click "Run".

The only drawback of BulkFileChanger is that the program cannot work with the attributes of folders and subfolders. However, for editing time stamps, it is perfect!

In addition, the utility has one more function - "Run command for selected files". This allows, for example, to generate a batch command for multiple files without having to manually enter all of their addresses!

conclusions

Today's article turned out to be not very extensive, but, I hope, it will be useful to someone, and to someone, perhaps, it will allow you to save extra nerve cells :)

Remember that 90% of the causes of all glitches and computer malfunctions are yourself! Therefore, before you panic and carry your PC for repair, try to analyze all your actions and look for solutions to the problem on the Internet. In most cases it helps;)

P.S. It is allowed to freely copy and quote this article, provided that an open active link to the source is indicated and the authorship of Ruslan Tertyshny is preserved.

ATTRIB command used to change the attributes of one or more files. In order to view the attributes of a particular file, you must click on it right click mouse and select the item properties. For example, let's create on disk "C" text file"Atribut.txt". Right click on this file and in context menu select the item "Properties".

Read-only file attribute prohibits making changes to it. If this attribute is set (there is a check mark in the “Read-only” field), then the user can open this file, write information to it, but when trying to save, a message will appear that these actions require administrator rights. Although setting this attribute does not allow making changes to the file, this file can be deleted, copied, moved to another location, renamed.
Hidden file attribute makes files invisible in explorer. For example, if you set this attribute (check the "hidden" box), click "Apply" and "Ok", the file will disappear from the explorer (become invisible). To display hidden files in Windows7, you can do the following: go to Explorer, click Organize, then Folder and Search Options, then View. Here you need to check the "Show hidden files, folders and drives" item. Then click "Apply" and "Ok".

The System attribute is automatically set by the operating system for all important system Windows files... It is impossible to change this attribute through the file properties, since there is no such field (this can be done via the command line). System files are automatically set to "Hidden". To display system files in Windows7, you can do the following: go to Explorer, click Organize, then Folder and Search Options, then View. Here you need to check the item "Show hidden files, folders and drives" and uncheck the box next to the item "Show protected system files" Then click "Apply" and "Ok".

As a result, you will have several new files on the C drive (IO.SYS, MSDOS.SYS, etc.). It is not recommended to enable the display of system and hidden files and folders. there is a high risk of moving or deleting an important file.

When you press the "Other" button in the file properties, a window will open additional attributes.

Archive attribute set in the "File ready for archiving" item. If this item is checked (as in Fig, below), then this file has an archive attribute. The archive attribute is required to create a backup copy of the file when archiving. If the attribute is set, then the program Reserve copy will create a copy of this file and reset the attribute. Accordingly, at the next backup copy of this file will not be done because the archive attribute has been cleared, which means that the file has already been backed up. However, when changes are made to this file, the operating system will automatically set the archive attribute so that a copy of this file will be made the next time it is backed up.

The "indexing" attribute. Above the "File ready for archiving" item is the "Allow indexing of the contents of this file in addition to the file properties" item. By default, this attribute is set for all files. Indexing is necessary for more quick search desired files on your computer. During indexing, the operating system creates special files where it puts the index. When searching desired file it is not searched for on the hard disk, but in the index. The operating system is constantly (in background) indexes the most common files.
Attribute "Compress content to save disk space" required to compress files and folders. Setting this attribute works by analogy with various archivers (for example, WinRaR). Compression using the attribute does not require unpacking files when working with them, however, the compression ratio is not as high as that of archivers. The names of files and folders with this attribute set are highlighted in blue. When setting this attribute to a folder, you will be prompted to apply compression only to the folder, or to the folder and all its subfolders.


The quality of compression can be viewed in the "properties" of the folder, where the size of the folder will be indicated, and how much space this folder takes on disk.

Attribute "Encrypt content to protect data" allows you to encrypt a file or folder. When this attribute is set, the file or folder will become available only to the user who is logged in with account at which the attribute was set. Other users will not be able to view encrypted folders and files if they do not have a password. The password is generated during the first encryption. Windows will prompt you to create backups your encryption certificate and encryption key. You will need them if you are logged in with a different account. You will need to enter a password to access encrypted folders and files. If you move an unencrypted file to an encrypted folder, it will be automatically encrypted. All encrypted folders and files are highlighted in green.

ATTRIB command makes it possible to change the attributes of a file by command line... The command has the syntax: ATTRIB [-A] [+ A] [- S] [+ S] [- R] [+ R] [- H] [+ H] [- I] [+ I] [Disk:] [ Path] [File name]. The letters A, S, R, H, I mean respectively: archived, system, read-only, hidden, non-indexed content. The "+" and "-" signs mean setting and unsetting the attribute, respectively.

For example, will create a file "atribut.txt" on the C drive. By default, this file when created has only the archive attribute and the "indexing" attribute set. Let's change the attributes of this file by setting the "Read-only" attribute and unchecking the "archived" attribute: attrib + r –a atribut.txt

As a result, the archive attribute will be removed from the file "atribut.txt" and the attribute "Read only" will be set.
ATTRIB command / S switch indicates that file attributes are changed not only in the specified directory, but also in all subdirectories. For example, let's create an "atribut" folder on the D drive, inside this folder, create two more folders "atribut1" and "atribut2". Let's create several files in each of these folders. Then the command attrib + r -a d: \ atribut \ *. * / s will change the attributes of all files located in the "atribut" directory and in its "atribut1" and "atribut2" subdirectories.

The ATTRIB command applies not only to files, but also to directories. For example, attrib + h d: \ atribut will set the Hidden attribute for the atribut folder.

Each file or folder in Microsoft Windows XP can have its own set of attributes that indicate some of the possible uses for a given file object. In the FAT file system, there are three main attributes of files and folders:

    Read Only - the mode of protecting files from accidental changes, editing or destruction of the information stored in it. If a file or folder is in read-only mode, it will not be possible to write to it;

    Archive is an attribute of a file or folder that indicates that this file object is subject to compression and its contents can be compressed using special programs. It should be borne in mind that when this parameter is changed for a group of objects, the attribute may be unavailable if part of the files from the selected array is to be archived, and the other part is not;

    Hidden - a parameter indicating that this file object is hidden and, under normal conditions, operating system Windows XP will not be displayed. Hidden files and folders cannot be used, modified, or opened unless their name is known. This attribute is commonly used to protect file objects from accidental deletion.

The attributes assigned to each of the file objects are indicated in Windows XP using a special character set: R - for the "Read-only" attribute, H - for the "Hidden" attribute, A - for the "Archive" attribute. The list of attributes assigned to a file or folder can be seen in the File manager attributes field in Explorer: for example, if the RHA designation is displayed for a file object in this field, this means that the file is hidden, archived and read-only; if this designation is formulated as RA, therefore, the file is opened for reading only and is archived.

You can change the attributes of a file or folder as follows: right-click on the file object's icon and select Properties from the context menu that appears. In the lower part of the file or folder properties window that opens, you will see a list of the attributes assigned to this file object. The assignment or removal of attributes of files or folders is carried out by setting or unsetting the corresponding checkboxes (Fig. 8.1).

In the file NTFS system In addition to the attributes of file objects described above, two additional ones are distinguished:

    Compressed - the file or folder is compressed by software NTFS;

    Encrypted - The file or folder is encrypted using the internal NTFS encryption algorithms.

Rice. 8.1.

Access to the management of these attributes of file objects is carried out by clicking the Advanced button in the General tab of the file or folder properties window.

Lets you view, set, or clear file or directory attributes such as Read Only, Archived, System, and Hidden. Command executed without parameters attrib prints the attributes of all files in the current directory.

Syntax

attrib [{+ r|-r}] [{+ a|-a}] [{+ s|-s}] [{+ h|-h}] [[disk: ][way] File name] [/ s[/ d]]

Options

+ r Sets the read-only attribute. -r Remove the read-only attribute. + a Setting the "Archive" attribute. -a Removing the "Archive" attribute. + s Set the attribute to "System". -s Removing the "System" attribute. + h Set the "Hidden" attribute. -h Remove the "Hidden" attribute. [ disk: ][way] File name Specifies the location and name of the directory, file, or set of files whose attributes you want to view or change. Wildcards (? And *) are allowed in the parameter to process a group of files. File name... / s Execute command attrib and all command line options for the corresponding files in the current directory and all its subdirectories. / d Execute command attrib and all command line options for directories. /? Displays help on the command line.

Notes

  • Working with groups of files

    You can use the wildcards (? And *) in the parameter to view or change the attributes of a group of files. File name... To change the attributes of system or hidden files, you first need to clear the corresponding attributes.

  • Using the Archive Attribute

    The "Archive" attribute (that is, the parameter + a) is used to mark files that have changed since the last backup. This attribute is used in the command xcopy... For more information about the Archive attribute and the command xcopy click the xcopy link.

  • Command attrib with different parameters is available in the Recovery Console.

Examples of

To display the attributes of the News86 file located in the current directory, enter the following command:

To assign the Read-only attribute to the Report.txt file, enter the following command:

attrib + r report.txt

To remove the read-only attribute from files in the \ Public \ Jones directory on drive B and all of its subdirectories, enter the following command:

attrib -r b: \ public \ jones \ *. * / s

Suppose you want to give a colleague a drive that contains files from the current directory on drive A, excluding files with the extension .bak. Since to copy files with the "Archive" attribute set, the command xcopy, you must set this attribute for all files to be copied. First, set the Archive attribute for all files on drive A, and then clear this attribute for .bak files. For example, enter the following command:

attrib + a a: *. * attrib -a a: *. bak

Now, to copy files from drive A to drive B, use the command xcopy... Launched with parameter / a command xcopy will copy only files with the "Archive" attribute set. For example, enter the following command:

If you want to remove the attribute Archival from the copied files, use the command xcopy with parameter / m instead of / a... For example, enter the following command:

For questions, discussions, comments, suggestions, etc., you can use the forum section of this site (registration is required).

File attributes

Each file has a number of characteristic properties - attributes... The most important attributes of the file are: name, extension, length, time and date of creation. File name... The name, or the name of the file, just like the name of a person, the name of a document, a book, serves to be able to distinguish one file from another, to point to the desired file.

File extension... In addition to the name, each file may or may not have an extension. The extension is used to characterize the contents of a file in a certain way. For example, the doc and txt extensions indicate that the file contains some kind of document or text, and extension bmp has a file containing an image in bitmap format. The extension, if any, is separated from the file name by a period. In the MS DOS operating system, the extension can contain from one to three characters, for example, otchet4.doc, vedzarpl.txt, picture.bmp, and in Unix systems and Windows 9.x more than three characters are allowed. If there is no extension, then the period is not put in the file name. The name, together with the extension, is called the full file name. File length. The next important attribute of a file is its length. The file length is equal to the size of the disk or tape area occupied by the file, and, therefore, is measured in bytes. The value of this attribute is used to determine the possibility of placing a file on a free area of ​​disk media and for some other purposes. File creation time and date... When you first write a file to disk, or when you make changes to the file using the system clock ( special program, which is part of the operating system), the time and date when the file was written to the disk device are automatically recorded. When the computer is turned off, the system clock is supported by special batteries or other power sources.

v operating system MS DOS files have four more attributes - read-only, system, hidden and archive... Each of these attributes has exactly two states - the attribute is enabled or the attribute is disabled. Enabling a read-only attribute(sometimes called the access control attribute) means that the file is not available for making any changes to it. It also makes it more difficult to destroy such a file. After turning off the read-only attribute, the file is available for any operation. System attribute usually only included in the core operating system files. For all other files, the system attribute is usually disabled. Attribute hidden it is included for those files that, when viewing the list of files on the disk device, are not included in this list by the operating system command. The rest of the files have the hidden attribute value turned off. To ensure the reliability of information storage on disk devices, you must have one or two copies of files containing important information. For this, they will organize archive files... When writing a file to an archive, the archive attribute is included. This means that a copy of the latest version of the file is in the archive. When making any changes to such a file, the archive attribute is disabled. This means that the archive contains an outdated version of the file (or the file is not archived at all). Special archiving programs, tracking the value of the archive attribute, can update in the archive only those files in which changes have been made. This allows you to optimize the work of archivers.