8 November 2015

How to Permanently Hide File or Folder in Windows - 2 Ways

Leave a Comment
In today's Life, almost all paperwork can be done on computers. We often save number of files on them like Documents, Videos, Images, Softwares etc., some of which are very important for us which need to be kept safe for future use. Especially when we're using multi user computer. There may be chance to lose them. Sometimes we delete them by mistake. So to prevent such conditions, the ultimate solution is to hide them.

Hide File or Folder in Windows

Most of us have windows installed in our computer. Didn't you have the same? Windows have inbuilt feature to hide files. Now let me ask you one question. Did you still think that this method can permanently hide any file or folder? Most probably NO. Why? Because everyone know about it and it can be easily unhide in just 3-4 steps. I personally find this method to be unsafe if you really want to hide some confidential data.

Now we are left with two options only. One is by using softwares and other is what I am going to discuss today. Before I start, lemme let you in short about what we're going to do. We will simply use command prompt and notepad ( based on batch programming ) to achieve this task as like Developers do. Our ultimate aim is to do same thing in both cases. So lets start!

Method 1 - Using Windows Command Prompt

We all know what command prompt ( also called cmd or cmd.exe ) is? In short, it is an official command-line interpreter for windows. There are number of commands available for cmd. Today we will make use of one of its command named as "attrib". All step by step instructions are given below -

1. First of all, you've to note the path location of file/folder you want to hide. To do so : right-click on file/folder and choose Properties.

2. Now copy the text under location and add file name after it. ( Note: Don't forget to add file type also ).

For Example: If I want to hide pdf file named as "school-project" and saved in "C:\Downloads\Documents" location, then the complete file address will be - C:\Downloads\Documents\school-project.pdf

In case of folder - C:\Downloads\Documents\old-files , Where old-files is folder name.

Get Complete File Location using General Properties

3. After above steps, go to start menu and search for cmd.exe.

4. Right click on program and run as administrator. ( It may ask to allow permission. Simply click OK button or give password ).

5. Now you have to write same command as I mentioned earlier i.e., attrib command. Below is the syntax to use it.

attrib +s +h file or folder location

Again I am using same file location as school-project. Here goes example -

attrib +s +h C:\Downloads\Documents\school-project.pdf

Command Prompt - Attrib

Command prompt doesn't allow to copy paste any text. So you need to write above code manually. At last hit enter button and see the magic. It will permanently hide your file and no one can find it except you. Yeah! I am 100% sure about it. Now the question is how you can unhide it in future? Simply follow above steps and change 5th step command to -

attrib -s -h file or folder location

Summing up this, we can say that "+" (plus) sign will hide it and "-" (negative) sign will unhide it.

Method 2- Using Notepad Batch Program

As like first method, this one also use same command. The only difference is that, we'll create a program. Notepad is not the tool to save text files only. It is widely used for programming purpose. One of them is Batch, which is the official windows programming language. I have created a simply program in this same language which can help you to hide file/folder in easy steps and interesting thing is, you don't need to do anything.

1. Simply open notepad from start menu and copy paste below batch code -

@echo off
title Hide Program
color 0a
echo Menu List -
echo 1. Hide Files
echo 2. Unhide Files
echo 3. Exit Program
set /p choice=Choose any one Option ( 1,2,3 ):
if '%choice%'=='1' goto hide 
if '%choice%'=='2' goto unhide 
if '%choice%'=='3' goto exit
if any %choice%== goto wrong
set /p loc=please write the path location here-
attrib +s +h %loc%
echo Successfully Completed! Press any key to exit.
set /p loc=please write the path location that you want to unhide-
attrib -s -h %loc%
echo Successfully Completed! Press any key to exit.
echo Are you Sure you want to exit?
echo You typed wrong Input. Try Again!

2. Now click on "File>Save As" and name this program as you want. Make sure to add ".bat" after name as it is file type extensions for batch programs.

3. Choose the location to save.

Save Batch Program

4. Finally hit save button and run it as administrator ( you need to run it as administrator each time you want to use it. Otherwise it may not work properly. ).

As it open, a simple menu will appear . Just choose any option as per your choice and follow on-screen instructions. If it ask to write path location, write the same location as we retrieved in 2nd step of 1st method.

Explanation of Code

Although code is very simply to understand and contain pure English but Newbies will find it hard to get. Don't worry. I will explain it. There are only 4 commands which are the building block of this program. All of them are listed below with their use and explanation.

Operator/CommandExplanation & Use
set /pThis will help to get input from user and store it in variable. Here variables are loc and choice.
if conditionThis command will match user input with specified numbers ( here with 1,2 & 3 ) and if found correct, then execute label tag after goto command.
attribAs already explained, this is the main command which will hide and unhide files using "+" and "-" symbol respectively.
% ( Percent )This operator is used to carry variable and print it whenever needed. Here it will add user input ( saved in loc and choice variable ) inside attrib command.

Final Words!

So Above are the best 2 Methods you can try. Just choose any of them and enjoy hiding your confidential data. One thing to keep in mind is that, you should not forget the path location of hidden file or folder. If lost, then it may be hard for you to recover. I prefer to store it in notepad txt file so that you can remember it later. or else you can remember the sub-folder location and use this command.

attrib -s -h sub-folder\*.*

Here asterisk ( * ) is a wildcard to fill blank spaces before and after "." ( dot ) i.e., to fill both filename and filetype, ultimately unhiding all types of file and folder inside sub-folder. For Example :

Example: attrib -s -h C:\Downloads\Documents\*.*

Give a try to above code. Finally if you've any doubt or query on this topic, feel free to comment below. Did you know any other best method than these 2?

Leave A Comment