There is a virus in our network that sets all root directories attributes hidden & 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:
attrib -s -h -r /d /s
del /q /s *.lnk
rd /q /s recycler
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).
Is there a possibility to process only directories NOT files and not recursively with a bat-file?
Like in perl:
opendir D, '.';
while($_ = readdir D){
if(-d $_){
#do something
}
}
closedir D;
Thank you.
—
UPD: 2012-01-31, the solution:
for /f "delims=" %i in ('dir /ad /ah /b') do @attrib -r -s -h -a "%i"
(replace %i with %%i to use in batch files)
Use the FOR command, with a DIR output as working list.
For example you start with this :
Where a, b, c and d are directories, and a has subdirectories. Type this command (remember to use %% if you put in in a batch file) :
Which will give you what you want :
From your question, I understand that processing subdirectories should be avoided. If not, comment on my answer and I’ll fix it.