Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sohan5005/c5a4756bbbd53291fcd6a18fdcd3977f to your computer and use it in GitHub Desktop.
Save sohan5005/c5a4756bbbd53291fcd6a18fdcd3977f to your computer and use it in GitHub Desktop.
System hide/unhide a folder or file
@ECHO OFF
TITLE System Hide/Unhide directory or file
GOTO :SET_DIR
:SET_DIR
SET /P DIRNAME=Enter file/folder name:
IF NOT EXIST %CD%\%DIRNAME% GOTO :NOTHING_FOUND
:CHOICE
CLS
ECHO file/folder name : %DIRNAME%
SET /P C=Do you want to (H)hide this or (U)unhide this? [H/U]
IF /I "%C%" EQU "H" GOTO :HIDE_NOW
IF /I "%C%" EQU "U" GOTO :UNHIDE
GOTO :CHOICE
:HIDE_NOW
ATTRIB +S +H "%CD%\%DIRNAME%"
ECHO Successfully hidden
GOTO :DO_AGAIN
:UNHIDE
ATTRIB -S -H "%CD%\%DIRNAME%"
ECHO Successfully unhidden
GOTO :DO_AGAIN
:NOTHING_FOUND
CLS
ECHO Nothing found at "%CD%\%DIRNAME%"
GOTO :SET_DIR
:DO_AGAIN
SET /P C=Do you want to do more? [Y/N]
IF /I "%C%" EQU "Y" GOTO :SET_DIR
IF /I "%C%" EQU "N" GOTO :EXIT_NOW
CLS
GOTO :DO_AGAIN
:EXIT_NOW
CLS
ECHO Thank you for using my script!
ECHO Follow me on:
ECHO Facebook: fb.com/sohan.zaman
ECHO Github: github.com/sohan5005
PAUSE
EXIT
@sohan5005
Copy link
Author

For Windows O/S only!

  1. Create a text file and rename the extension with extension .cmd or .bat
  2. Move the file to the same directory where your targeted file/folder is placed (For example, you wan to hide Movies folder which is located under D: drive directly, then place this file in D: drive directly too).
  3. Run the file and follow the process

Same process applies for hiding/unhiding

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment