tags:

views:

133

answers:

3

I want to hide multiple files with the attrib <file path> +s +h but it stops after the first folder. I have this...

@ech off
attrib z:\test +s +h
attrib C:\Documents and Settings\Administrator\Desktop\test +s +h

Yes, I have two drives. But it stops execution after the first folder. How do I make it execute both commands. I know about the call command, but is that the only way? There can't be this big of a flaw in DOS, where you can't execute multiple commands in one batch file.

A: 

you are missing the /S flag

Dani
+1  A: 

It should work fine if you haven't made a mistake (which you have - in DOS, the switches come before the folder). Try this:

@echo off
REM Add /s after the *.* to include subfolders
attrib +s +h z:\test\*.*
REM Note the double quotes around paths that have embedded spaces
attrib +s +h "c:\Documents and Settings\Adminstrator\Desktop\Test\*.*"

Again, your problem is you're doing "attrib [folder] [attribute switches]", where attrib.exe wants "attrib [attribute switches] [folder]" instead. Thanks to JimG for the correction. The problem is probably related to my second REM statement about the missing double-quotes around the path with spaces.

For more info about attrib.exe, type this at a command prompt:

C:\> attrib /?
Ken White
attrib works fine with the switches after the file as well.
JimG
@JimG: Thanks for the correction. I did the "attrib /?", and it specified them first; however, I just tested and you're right. :-)
Ken White
A: 

Your second command doesn't work because you haven't quoted the path with spaces in it. Either that, or you have a batch file called attrib.bat on your path before attrib.exe (but I doubt this is the case). You could test it by using attrib.exe instead of just attrib.

CALL is only necessary for running other batch files, not .exe files.

JimG