# Solved: Hide/Unhide Batch File



## Nerokin (Feb 27, 2013)

I would like a batch file that can hide/unhide folders, but with more features that allows you to type a folder location and it would (un)hide the folder that you typed in. I think I have an idea on how it should look, but can't really make one of my own


> @echo off
> 
> cls
> ECHO Please type in the folder you would like to (un)hide
> ...


It may look like something like this, I am just submitting what I think it may look like.


----------



## Squashman (Apr 4, 2003)

```
@echo off

:_ASK
cls
ECHO Please type in the folder you would like to (un)hide

set /P _folder=Enter the Full path to the Folder:

IF NOT EXIST "%_folder% GOTO _ASK

dir /b /a:hs "%_folder%" 2>nul
if %errorlevel%==0 (
	attrib -h -s %_folder%
	) ELSE (
	attrib +h +s %_folder%
)
```


----------



## Nerokin (Feb 27, 2013)

Thanks, that was quick! I hope this works.


----------



## Nerokin (Feb 27, 2013)

It doesn't work... It may be the computer I am using. I have a batchfile that was suppose to hide folders, but it hides .exe files and other batchfiles (including itself).


----------



## Squashman (Apr 4, 2003)

Telling me it doesn't work isn't really giving me any indication as to what is not working or what is going wrong.
Nor does it tell me how you are executing the batch file and what you are inputting into the script when it prompts you to put in a folder name.

Put double quotes around all the variables. I see I missed a few.

Open up a cmd prompt and execute the batch file from the cmd prompt.
Copy and paste all the execution in the cmd window to the forum.


----------



## Nerokin (Feb 27, 2013)

Well... I came up with a batch file you could "clean up" your desktop with. I hope this is a wee bit better than just repeating that it doesn't work.



> @echo off
> Title (Un)Hide Folders
> cls
> :start
> ...


To get it to work change *USERNAME* to the username you use and add a folder that is on your desktop and add the name to that folder that you want to hide



> :num1
> Set _Path=C:\Users\Nerokin\Desktop\CursorFX
> For /F "Delims=" %%I In ('Attrib "%_Path%"') Do Set _Attribs=%%I
> If "%_Attribs:~4,1%"=="H" (
> ...


----------



## Squashman (Apr 4, 2003)

You know you dont have to repeat the same code over and over.


----------



## foxidrive (Oct 20, 2012)

Nerokin said:


> To get it to work change *USERNAME* to the username you use and add a folder that is on your desktop and add the name to that folder that you want to hide


There's a setting in Folder Options to view system and hidden files. Just so you know that your code won't do anything if that is selected.


----------



## Nerokin (Feb 27, 2013)

I have checked that and still haven't seen any of the folders that are hidden. I had to use a third-party exe to see the hidden folder.

























Note: The Third Party Viewer only displays folders not EXE files.


----------



## Squashman (Apr 4, 2003)

Thats because you used +S and you have the box checked to not show system files.


----------

