Author Options:

what is a wildcard for folders in batch? Answered

I am making a batch file to hide files and folders, what would be the wildcard to hide all folders, like *.* for files?



You should use *.
so to hide your folders
attrib *. +h /s /d

Doesn't work, even when run as an administrator it says access is denied and lists that before each file, but also shows hundreds or more names than are in the directory. Let me put it up...

@echo off
color 0a
set /p note=
if '%note%'=='password' GOTO SHOW
if '%note%'=='lockup' GOTO HIDE
if '%note%'=='*' GOTO INTRUDER

attrib *. =h /d


attrib *. +h /d
attrib -h Resources.bat


attrib *. +h /s /d (this should work - just checked it of xp and win7 - could you try it out in a command prompt) - it looks likes attrib doesn't process the directory wildcard, it simply processes the directories if you include the switches so even attrib +h /s /d should do what you want

You can only use the /d switch with the /s switch... permissions will come into it, depending on where you run the batch file... to change the attributes of system files you will have to include the system file attribute... let me know how you go...

I assume the equal sign you have under :SHOW is a typo...

it just keeps saying "paramater format not correct -"

I would suggest that the "Access Denied" messages are due to some of your program files folders/files having limited administrator permissions set... you can either change these using explorer (Tools-Folder Options-View tab-Advanced settings-uncheck use simple file sharing and then just right click on folders etc to see security permissions tab)... or you can use cacls in the command prompt (this is a useful tool). The security permissions exist when using NTFS as your file system.

Re: parameter format not correct... Can you try using the attrib command in a test directory on your desktop to see if you can get it working there... if you are specifying paths then use 8:3 format or use quotes (given spaces etc)... I'm using XP Pro and Win7 with no such issue... hopefully you can work out what is causing you a problem. All the best.

LOL yeah. When I'm spitting out lines of batch stuff that always get's mixed up. I usually notice it though. I am running it in the program files (86) folder, and even when ran as an administrator it doen't work, plus it tries hiding stuff to do with drivers an other things. I just want it to hide everything in the folder it is in except itself.


7 years ago

Well For some reason it works with just

attrib Directoryname +h +r

is the directory has spaces you just use ".

Remember that "folders" are what the command line calls "directories".