DEV Community

Victor James
Victor James

Posted on • Originally published at windowscmd.com on

Attrib

Attrib – This command allows you to display or change the file attributes.

CMD Line

CMD Line is a text-based interface that transfers the command from the user to the OS.

CLI-Command Line Interpreter

The command-line interpreter (CLI) for windows is CMD.EXE. Also, you can use PowerShell which can automize many system administration tasks and these tasks are not approachable in command prompt. With the help of the CLI, you can communicate with your system by typing the text in commands. As a result, your system answers to the text that you have typed previously, and then the user can proceed with the next command line that shows up.

To open the Run command Window

Run command window helps you to run programs, open the files and folders. And there are several ways to open up the run command dialog box. This run command box is useful for you to head straight to the destined program easily.

By using the Keyboard shortcut Key:

WINDOWS+R

The shortcut key method to the run command box is the most commonly used one. Also, this method is in all versions of Windows. You need to press the Windows+ R key concurrently to open the Run command dialog box.

Run command box
Run command box

How does Attrib command work?

This command is to set or display the read-only, archive, system, and hidden attributes of a file. In case if you define the file as a read-only file , you can only refer to or read the file, but you cannot change the file.

Syntax


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

Enter fullscreen mode Exit fullscreen mode

Key explanation

In this syntax:

+ -Turns an attribute on

-Clears an attribute off

For example,

If a file has an attribute of -R, the file type can be referred to as a read and write file type.

In case if a file has an attribute of +R , you have only access to read.

  • Pathname -specifies the filename,
  • /S -This one searches the pathname that includes all the subfolders.
  • /D – To Process folders as well
  • / L -Work on the attributes of the symbolic link, rather than the target of the Symbolic link.

Attributes

  • +R – The +R Read-only files.
  • -R – The -R can be read, altered.
  • + A – The +A is to set the ARCHIVE attribute.
  • A – Use the -A is to turn off the ARCHIVE attribute.
  • +H – +H option is to set the HIDDEN attribute of a file.
  • H – The -H option is to turn off the HIDDEN attribute.
  • +S – The +S option is to set the SYSTEM attribute of a file.
  • -S – Use the -S attribute is to turn off the SYSTEM attribute.

Extended attributes

  • B – SMB Blob Attribute (Windows 10)
  • E – Encrypted
  • C – Compressed (128:read-only)
  • I – Not content-indexed
  • N – Normal (0: cannot be used for file selection)
  • O – Offline
  • P – Pinned attribute refers to the “Always available on this device” setting for OneDrive files.
  • T – Temporary
  • X – No scrub file attribute (Windows 8+)
  • U – Unpinned Attribute (Windows 10)
  • V – Integrity attribute (Windows 8+)

The numeric values can be applied when modifying attributes with VBS/WSH. In case if there are no attributes defined , attrib will return the current attribute settings.

/S -option ATTRIB helps to search a particular filename.

  • To clear the hidden and system attributes for the RECORD.TXT file type. If a file has the System or Hidden attribute set, you must clear that attribute before you can change any other attributes with ATTRIB.

ATTRIB -S -H RECORD.TXT

Enter fullscreen mode Exit fullscreen mode
  • To hide the directory C:\SECRET

ATTRIB +H C:\SECRET

Enter fullscreen mode Exit fullscreen mode
  • For to use ATTRIB with a directory , you must explicitly specify the directory name thus the respective command would change only files, and not directories :

ATTRIB +H C:*.*

Enter fullscreen mode Exit fullscreen mode

DFSR will not copy files if they have the Temporary attribute set. The temporary attribute can be removed by using PowerShell to subtract 0x100


PS C:> Get-childitem D:\Data -recurse | ForEach-Object -process {if (($_.attributes -band 0x100) -eq 0x100) {$_.attributes = ($_.attributes -band 0xFEFF)}}

Enter fullscreen mode Exit fullscreen mode

Verdict

In this article, we have discussed the Attrib command that allows you to display or change file attributes. If you have questions related to the articles, let us know in the comment section.

Read further:

  • CD This windows command-line tool changes the directory and moves to the specific folder. CHDIR is the equivalent word of CD.
  • CMD CMD windows command is to start a new shell in a command or executable program.
  • Attrib The Attrib command-line tool is to display or change the file attributes.
  • CHDIR The CHDIR command Changes the Directory and moves to the specific folder.
  • CLS CLS command is to erase all characters and graphics from the screen. To be more precise, this command clears the screen.

The post Attrib appeared first on Windows Commands- SS64 Commands.

Discussion (0)