0

I had a virus or something on my computer that set the attributes for all the folders in the root of my external drive to system and hidden, and created shortcuts to them. I am now trying to remove these attributes all at once with the following command, but it doesn't do anything:

dir /ash /b | attrib -h -s

According to my understanding of the documentation of these commands, this should work. Is there something wrong here?

Thanks

2 Answers2

1

Yes. The pipe | redirects program 1’s output to program 2’s input. However, your program 2 (attrib), does not read any input. It wasn’t written to do so. Instead, it expects file names in its command-line parameters.


There are some tools available in Unix-style systems to handle piping of arguments—though of little relevance here—they are:

  • xargs to handle such cases of converting text input into command-line arguments
  • find to handle this specific case of applying a command recursively
  • chmod command that has a “recursive mode” option

On Windows, without xargs, you will have to do something like:

for /f "tokens=*" %f in ('dir/b/ash') do @attrib -r -h -s "%~f"

Or maybe:

for /r . %f in (*) do @attrib -r -h -s "%~f"
Tim
  • 7
grawity
  • 501,077
1

Actually you can do it in a much easier fashion:

attrib e:\*.* -s -h /s

This will remove all the system and hidden attributes starting at the root of the E: drive and all its sub-directories. The /s tells attrib to process sub-directories.

Tim
  • 7
Keltari
  • 75,447