What Is This Attrib Command Saying?

What Is This Attrib Command Saying?

Could anyone tell me what this command says? I used this command when I couldn't find my files on my flash drive. but I don't know what it is saying, I only know -h and -r which remove the hidden and read-only attribute, respectively.

attrib -h -r -s /s /d g:\*.*

2 Answers

DavidPostill's answer lists the meanings of all attrib's switches. Let's use that to interpret that specific command:

  • -h removes the hidden attribute (so the items will show up in Explorer)
  • -r removes the read-only attribute
  • -s removes the system attribute (also so the items will show up in Explorer)
  • /s makes the command look in all subfolders recursively
  • /d makes it apply the attributes to folders too (not just files)
  • g:\*.* is the path to apply the changes on

So, I conclude that the command was meant to unset all attributes from everything on the G drive (*.* means all files with an extension; * is a wildcard that matches one or more characters. The /s makes it do everything in all folders under your starting directory, g:\.)

If you're trying to find a file, that command might make stuff show up in Explorer (assuming you're not showing hidden/system files anyway), but it won't magically tell you the location of whatever you're looking for. To find a specific file, try Explorer's search feature.

1

What does this command mean?

attrib -h -r -s /s /d g:\*.*

Run attrib /? to get help:

F:\test>attrib /?
Displays or changes file attributes.

ATTRIB [+R | -R] [+A | -A ] [+S | -S] [+H | -H] [+I | -I]
       [drive:][path][filename] [/S [/D] [/L]]

  +   Sets an attribute.
  -   Clears an attribute.
  R   Read-only file attribute.
  A   Archive file attribute.
  S   System file attribute.
  H   Hidden file attribute.
  I   Not content indexed 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.
  /L  Work on the attributes of the Symbolic Link versus
      the target of the Symbolic Link

Notes:

  • attrib goes into a lot more detail about the attrib command.

Further Reading

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

James H. Sterling
Author

James H. Sterling

James Sterling reports on renewable energy developments, climate policy, ecological conservation, and green tech innovations around the globe.