- The attrib command allows you to view and modify in bulk the R, A, S, H attributes and other advanced values of files and folders.
- Windows manages many more internal attributes (compressed, encrypted, indexed, temporary, offline) that can affect backups, visibility, and performance.
- By combining attrib with dir, tree, for, xcopy, copy, move, and ren, it is possible to automate listing, creating, organizing, and renaming large volumes of files.
- The console is key to recovering files hidden by malware and to cloning or cleaning folder structures without the need for external tools.

If you work with many files in Windows, sooner or later you will need touch file and folder attributes: making them read-only, hiding them, marking them for backup, or even recovering them after malware has rendered them invisible. All of this is done, primarily, from the Command line.
In this guide you will see, in an organized and detailed way, How to use the attrib command and other terminal commands To list, change, and automate the handling of attributes and large volumes of files and directories in Windows. You'll see complete syntax, practical examples, tips for real-world scenarios (such as cleaning an infected USB drive), and a clear explanation of what each internal Windows attribute means.
What are file attributes in Windows?
In Windows, every file and every folder has a series of binary attributes that activate or deactivate behaviors: whether it can be modified, whether it is visible in Explorer, whether the system treats it as a system file, whether it is compressed, encrypted, prepared for backup, etc. These attributes do not depend on the user or NTFS permissions.
In other words, when you put a file like read-only attributesThat mark applies to all system users, including administrators. NTFS Permissions and ACLs They are a separate layer; attributes are global properties of the file.
We can change those attributes in two ways: graph from the File Browser or via the console with the command attribIn addition, there are third-party utilities for viewing and modifying advanced attributes and metadata more easily.
attrib command: syntax and parameters
The command attrib It serves for show, assign or remove attributes to one or more files and directories. If you run it without parameters, it will list the attributes of all files in the current directory.
The general syntax of the command in modern versions of Windows is:
attrib ]
Each block of syntax allows activate (+) or deactivate (-) a specific attribute, and at the end it indicates which files or folders it applies to, as well as whether it should be done recursively.
The boss Specify the file, folder, or set of files. You can use wildcards. * and ? in the name to affect groups of files (for example, *.txt o file?.bak).
Meaning of each attrib parameter
The main modifiers of attrib These are letters that represent attributes. They are always used with + to add the attribute or – to remove itLet's go one by one:
{+|-}r: sets (+) or clears (-) the attribute of read-only (R).{+|-}a: activates or deactivates the attribute of file ready for filing (A), used by backup programs.{+|-}s: marks or unmarks the attribute of system file (S).{+|-}h: assigns or removes the attribute of hidden file (H).{+|-}o: adds or removes the attribute of offline file.{+|-}i: manages the attribute of Not Content Indexed, which indicates whether the content should be excluded from the search index.{+|-}x: adds or removes the attribute of cleaning file (used by certain maintenance functions).{+|-}p: controls the attribute of anchored file (pinned).{+|-}u: controls the attribute of unanchored file (unpinned).{+|-}b: manages the attribute of SMR blob (used in certain disks and storage technologies).
In addition, there are modifiers that control how the command is applied in the directory tree:
/s: processes all files in the current directory and all its subdirectories./d: applies the changes to folders as well (by default it only affects files)./l: it acts on the symbolic link itself and not on the destination it points to.
If at any point you have any doubts about the version of attrib installed on your WindowsYou can view the built-in help with attrib /?, which will show the full syntax and available options depending on your system.
Classic attributes: R, A, S, H and other Windows internals
Aside from the command parameters, it's important to understand what the internal attributes that Windows uses, many of them visible in the console and in the file properties tab.
The most common ones you'll see at the exit of attrib are:
- R (FILE_ATTRIBUTE_READONLY – 0x00000001)Read-only. Prevents the file from being modified or deleted normally.
- H (FILE_ATTRIBUTE_HIDDEN – 0x00000002)Hidden. The file is not shown in standard listings unless you have the option to view hidden files enabled.
- S (FILE_ATTRIBUTE_SYSTEM – 0x00000004): system. Indicates that it is an internal operating system file.
- A (FILE_ATTRIBUTE_ARCHIVE – 0x00000020)Ready to archive. Marks the files that have changed and should be included in the next backup.
- D (FILE_ATTRIBUTE_DIRECTORY – 0x00000010): indicates that the entry is a directory.
- Normal (FILE_ATTRIBUTE_NORMAL – 0x00000080): file with no other active attributes. Used as a "clean" state.
- C (FILE_ATTRIBUTE_COMPRESSED – 0x00000800)Content compressed in NTFS to save space. It is usually displayed with a blue name in Explorer.
- E (FILE_ATTRIBUTE_ENCRYPTED – 0x00004000): File encrypted with EFS. Only the user who encrypted it can read it; it usually appears in green in Explorer.
- N (FILE_ATTRIBUTE_NOT_CONTENT_INDEXED – 0x00002000): excludes the contents of that file or folder from the search index.
- Offline (FILE_ATTRIBUTE_OFFLINE – 0x00001000): indicates that the data is not immediately available (e.g., archived in remote storage).
- Temporary (FILE_ATTRIBUTE_TEMPORARY – 0x00000100)The system can manage the file as temporary storage, prioritizing keeping it in memory.
Keep in mind that some attributes are not compatible with each otherFor example, a compressed file in NTFS cannot be encrypted at the same time, and vice versa.
View and change attributes from the console
The most direct way to check what attributes a file has is to use attrib with the appropriate path or wildcardsFor example, to list the attributes of all files in a folder:
attrib "c:\attrib\*.*"
The output will show one letter for each active attribute followed by the full path, something like this: A R o H R before the file nameIf you simply run attrib While inside the folder, you will see the same information without explicitly specifying the path.
To view the attributes of a specific file in the current directory, it could be as simple as:
attrib news86
If what you want is set a file to read-only, for example report.txtYou would use:
attrib +r report.txt
And if you need to remove that same read-only attribute from the set of files on a drive or folder, you could do something like this:
attrib -r b:\public\*.* /s
In this last case you would be unlocking the R attribute of all files Folder public of drive B: and all its subdirectories, thanks to the modifier /s.
Typical use of the Archive attribute with backups
Attribute A (Archive) It is widely used in backup strategies. When a file is created or modified, Windows usually activates the Archive attribute automatically to indicate that the file has changed since the last copy.
This behavior can be forced on a large scale. For example, to mark all files on drive A: as ready to archive:
attrib +a a:*.*
And then you could clean that attribute only in the backup or temporary filesfor example with extension .bak:
attrib -a a:*.bak
This is how you get backup tools (like xcopy or others) ignore certain files in their incremental executions.
Recover hidden files after malware using attrib
A very real and quite common case is finding a USB drive or external hard drive where malware has changed the attributes of all your files to hidden, read-only, and systemIn the Explorer it appears that "there is nothing", but in reality the content is still there.
In that scenario, you can use the command:
attrib -s -r -h F: /s /d
Here you are telling Windows that, on drive F:, Remove system (-s), read-only (-r), and hidden (-h) attributes of all files (/s) and also from the folders (/d). After a few seconds, the files will become visible again.
This type of use of attrib It is especially useful when the malware simply “Hide” your files by changing attributesinstead of encrypting or deleting them.
Graphical attribute management and third-party tools
If you prefer not to use a console, you can View and change many of these attributes from Windows ExplorerSimply right-click on the file, go to Properties and check the tabs:
- Eyelash General: Read-only and Hidden checkboxes; Advanced button for options such as compression, encryption, indexing, etc.
- Eyelash Details: displays a broader list of properties and attributes.
In NTFS compressed files, the name usually appears in color azulIn files encrypted with EFS, they are shown in green. This helps to identify at a glance which advanced attributes are active.
Also exist external utilities such as certain tools from AjpdSoft or others focused on metadata and extended attributeswhich allow you to view and modify all these values with greater granularity, beyond what is shown in the standard Windows interface.
List files and folders in bulk using dir and tree
When you're adjusting attributes on a large scale, it's almost mandatory to rely on listing commands like dir and tree to see what you have on your hands and generate useful lists.
The command dir It allows you to list the contents of a folder using a variety of filters. Some basic examples:
dir→ standard list of files and folders.dir *.ext→ Shows only files with a specific extension.dir /a→ includes hidden and system files.dir /b→ “basic” mode, file names only, no headers or totals.dir /o:s→ sort by size; there are many other sorting options.
If you need to save that list to a text file for documentation or review later, you can redirect the output with >:
dir /a /b > listado.txt
And if you want a more “visual” view of the structure, the command tree It generates an ASCII tree with folders (and optionally files):
tree carpeta→ shows only the directory structure.tree mi_carpeta /f→ also includes files in the tree.
Create files and folders in bulk
Besides playing with attributes, it is often of interest generate bulk stacks of files or foldersThe Windows console allows you to do this without needing to program anything complex.
To quickly create an empty text file, a classic trick is:
echo. > nombre_archivo.txt
And to create a new folder, the usual procedure is:
mkdir nombre_carpeta
The magic happens when you combine these commands with loops forFor example, to create a numbered sequence of files or folders, you can use:
for /L %i in (0, 1, 10) do echo. > "%i hola.md"
This command creates files from “0 hola.md” to “10 hola.md”. If you want directories instead of files:
for /L %i in (0, 1, 10) do mkdir "%i hola"
the modifier /L indicates to for that travels a numerical series (start, increment, end)which is perfect for templates, projects, chapters, etc.
Create files or folders from a list
Another very powerful trick is to use a text file as “name source”Imagine you have a fichero.txt with a list of titles or identifiers, and you want to convert each line into a file or folder.
To generate a file .md For each line of that file, you could execute:
for /f "tokens=*" %i in (fichero.txt) do echo. > "%i.md"
If you prefer to create folders with those names, simply change the command inside:
for /f "tokens=*" %i in (fichero.txt) do mkdir "%i"
The option "tokens=*" makes the entire line is collected, including spaces, which is ideal when names contain more than one word.
Organize files: one folder per file
A curious but quite common case, especially when managing content for blogs or large projects, is wanting to put each file in a folder with the same nameFor example, you have many .txt loose and you want each one to go to its own folder with the same name (without the extension).
This is achieved with a loop like this:
for %i in (*) do mkdir "%~ni" && move "%i" "%~ni"
Here %~ni is the name of the file without an extensionThe folder is created with that name, and then the file is moved into it. This is very useful for quickly organizing content that was previously all together.
Concatenate multiple text files into one
If you handle documentation divided into multiple files, you might be interested in this. combine everything into a single fileWith a loop for and the command type You've got it done:
for %i in (*.txt) do type "%i" >> archivo_salida.txt && echo. >> archivo_salida.txt && echo. >> archivo_salida.txt
This command iterates through all the .txt from the directory, it adds them to the end of archivo_salida.txt and, after each one, insert a couple of blank lines to better separate the content.
If you also want the source file name to be written before each block, you can use a variant:
for %i in (*.txt) do echo %i% >> archivo_salida.txt && type "%i" >> archivo_salida.txt && echo. >> archivo_salida.txt && echo. >> archivo_salida.txt
This generates a final document where Each section begins with the name of the original file, followed by its content.
Advanced file copying and moving
The basic commands for copying and moving are very simple, but combined with loops, they allow massive, very powerful operationsAt a simple level, you have:
copy archivo_origen directorio_destinomove archivo_origen archivo_destino
If you want, for example, copy the same file to all folders from a directory, imagine a readme.txt which should go in each subfolder. You can do:
for /D %a in (*) do (xcopy /Y readme.txt "%a")
the modifier /D This makes the loop only traverse directories, and xcopy /Y It copies the file by overwriting it without asking.Ideal for templates, license files, instructions, etc.
Clone folder structure without files
Sometimes you need to duplicate one complete directory structure, but empty, without files inside. This is easily achieved with xcopy and the appropriate modifiers.
To copy only the folders (without subfolders), simply:
xcopy ruta_origen ruta_destino /t
If you also want to include all subfolders, Add /e:
xcopy ruta_origen ruta_destino /t /e
The combination /t /e says a xcopy that Create the entire directory tree, but without copying the files, something very convenient for cloning project templates or environments.
Rename files in bulk
Another frequently repeated task when managing files is the massively renownedThe basic command is simple:
ren ruta_archivo nuevo_nombre
But things get interesting when you want to add prefixes, suffixes, or rename files in multiple folders at once. To add, for example, a prefix to all files in the current directory:
for %a in (*.*) do ren "%a" "prefijo - %a"
And to add a suffix to the end of the name (before the extension) you could use more advanced variants with variable expansion, but as a basic example:
for %a in (*.*) do ren "%a" "%a - sufijo"
If what you need is rename a specific file in many folders and subfoldersFor example, rename all the readme.txt a readme.mdYou can do:
for /R %G in (readme.txt) do ren "%G" "readme.md"
Here /R This indicates that the search is recursive. Each file will be located. readme.txt in the tree and will be renamed to the new extension.
Delete files and folders carefully
The console's delete commands are very powerful, so it's advisable Use them with extreme care.The basics are:
del nombre_fichero→ delete files.del /Q /F *.*→ deletes all files in the current directory, without asking (/Q) and forcing the deletion of read-only files (/F).rmdir nombre_directorio→ delete an empty folder.rmdir /S /Q nombre_directorio→ Deletes the folder and all its contents, including subdirectories, without asking for confirmation.
Before launching a mass deletion, it's usually a good idea to do a previous list with address to make sure you're on the right route and that you don't accidentally damage anything important.
With all of the above, the Windows console becomes a Swiss Army knife for anyone who needs to manage attributes and large volumes of filesYou can repair malware damage, prepare backups, automate project structures, rename and classify in bulk, or fine-tune performance by marking what gets indexed, compressed, or archived—all with a few well-thought-out commands.
Passionate writer about the world of bytes and technology in general. I love sharing my knowledge through writing, and that's what I'll do on this blog, show you all the most interesting things about gadgets, software, hardware, tech trends, and more. My goal is to help you navigate the digital world in a simple and entertaining way.


