title: Bat-File: Command to change only folders attributes not recursively
body: <p>There is a virus in our network that sets all root directories attributes hidden &amp; system at usb flash drives and creates lnk-files, that run cmd.exe, virus itself and then open directories, so to cure such drives I use the commands:</p>
  
  <pre><code>attrib -s -h -r /d /s
  del /q /s *.lnk
  rd /q /s recycler
  </code></pre>
  
  <p>But there is a problem: command "attrib -s -h -r /d /s" processes all files and directories recursively and if there are many of them it takes too long (it looks like Windows first creates full file list and then begins to processes everything).</p>
  
  <p>Is there a possibility to process only directories NOT files and not recursively with a bat-file?</p>
  
  <p>Like in perl:</p>
  
  <pre><code>opendir D, '.';
  while($_ = readdir D){
      if(-d $_){
          #do something
          }
      }
  closedir D;
  </code></pre>
  
  <p>Thank you.</p>
  
  <p>--
  UPD: 2012-01-31, the solution:</p>
  
  <pre><code>for /f "delims=" %i in ('dir /ad /ah /b') do @attrib -r -s -h -a "%i"
  </code></pre>
  
  <p>(replace %i with %%i to use in batch files)</p>