0

Hey guys i need to know how to hide a file of which i dont know the name of.

for instance i have 6 folders named 1-6 but i think that their named a-f. and their directory is C:\users\all users\bond.

how would i go about doing this?

I dont need to hide the directory of which the files are located i need to be able to enter the directory and hide the files within.

here's the only thing i can think of:

@echo off
cd C:\users\all users\bond
attrib +h +s %filename% *
echo.
echo files successfully hidden.
pause
exit
David Ruhmann
  • 11,064
  • 4
  • 37
  • 47
cmd
  • 563
  • 3
  • 10
  • 26
  • So you want to hide a all the files within a given folder? – David Ruhmann Feb 12 '13 at 03:57
  • yes, i dont want to hide the folder that the files are in but the files inside of the folder itself. so if i have the folder being TEST and the files being 1 2 3 i want to hide 1 2 3 and not hide TEST, but i need to be able to do it with only knowing that the folders name is TEST – cmd Feb 13 '13 at 21:55

1 Answers1

1

You could iterate over the folders.

The for command can takes a list of folder names or wildcards.

@echo off
cd /d c:\users\all users\bond
for /d %%D in (FOLDER NAMES GO HERE) do (
    pushd %%D
    attrib +h *.*
    popd
    )
exit /b

If you need to process all the folders in the current directory, just put * there:

...
for /d %%D in (*) do (
...

You could also not change to the parent directory but specify it in the for loop instead (note the quotes around the mask):

@echo off
for /d %%D in ("c:\users\all users\bond\*") do (
...

Similarly, you could omit jumping in to and out of each subdirectory and instead specify the path in the attrib command.

So, the above script could be rewritten like this:

@echo off
for /d %%D in ("c:\users\all users\bond\*") do attrib +h "%%D\*"
exit /b
Andriy M
  • 76,112
  • 17
  • 94
  • 154
  • I took the liberty of adding my suggestions on "enhancing" the script to your post. Please feel free to roll them back if necessary or edit them as you see fit. – Andriy M Feb 13 '13 at 07:13