How to Encrypt/Decrypt Files & Folders – From the Command Line (Cipher, CMD, DOS)

What We'll Learn:

This guide is all about encrypting or decrypting files and folders from the windows command line using the cipher command.

  • We’ll start by learning, exactly what the cipher command is and what function it serves.
  • We’ll then learn how to use it to encrypt or decrypt files and folders.
  • How to take advantage of wildcards to encrypt or decrypt multiple files or folders at once.
  • And finally, we’ll learn how to make deleted data completely unrecoverable using the cipher command.

Lets get started!

What Is The Cipher Command?​

The cipher command is a built in security tool, available in the windows command line, that can be used to perform a number of operations on your files and folders.

Cipher can come in very handy if you are constancy working with important files or manage sensitive data. 

That’s because cipher can be used to securely and fully encrypt and decrypt files or entire directories as well as securely wipe or overwrite deleted data making them unrecoverable.

We are going to learn how to do just that in this short guide.

If you would like to follow along, feel free to open your command line (not as an administrator) and create an empty file using the echo command and the grater than redirector as well as a folder using the mkdir command.

echo. > File.txt & Mkdir Folder

An empty file will be created at once in your current directory. 

We are going to use this file to practice a number of cipher commands starting with encryption and decryption.

How To Encrypt & Decrypt Using Cipher:​

Using the cipher command to securely encrypt a single file is extremely easy, simply type the cipher command along withe the /e parameter followed by the name of the file.

The /e parameter stands for encrypt.

Cipher /e File.txt

Your file will immediately be encrypted.

To undo the operation and decrypt the file simply replace the /e parameter with /d, which stands for decrypt.

Cipher /d File.txt 

To check whether or not your file was indeed encrypted/decrypted use the cipher command without any parameters followed by the name of your file or folder:

Cipher File.txt
How to Encrypt/Decrypt Files - Using the Command Line (Cipher, CMD)

The encryption status of your file or folder should appear at once.

  • If the result is U it means that the file is unencrypted.
  • If the result is E it means that the file is encrypted.

Typing the name of your file, only works on files that are located in the same directory as your command line, to encrypt a file that’s located elsewhere, type the path to your file followed by a backward slash and the name of your file.

For example to encrypt a file named “My File.txt” in your desktop directory use the following syntax:

Cipher /e "C:\Users\\My File.txt"

Replace with your computers username.

You might have noticed that i surrounded the location of the file in quotes, that’s because the path/location to the file contains a space within it.

Had i not added the quotes, the command line would not have been be able to find my file.

That’s because the quotes tell the command line that the words separated by the spaces are not an additional parameter and are just a continuation of the location or name of our file/folder.

So remember to always wrap quotes around locations or file names that contain spaces so that the command line knows how to properly search for your file.

The command for encrypting and decrypting a folder is exactly the same.

Cipher /e Folder

Replace the /e parameter with /d to decrypt the folder instead.

This operation however will only perform the operation on the folder itself and not any of the contents inside it.

To encrypt/decrypt every item within the folder you need to use the /s parameter. Here is what the command would look like:

Cipher /e /s:Folder

The specified operation will now be performed on all the contents inside your folder as well.

Encrypt & Decrypt Multiple Files/Folders At Once:​

So far we have been using cipher to perform an operation only a single file or folder.

We can encrypt/decrypt  multiple files or folders at once either by typing their names one after the other, for example:

Cipher /e File1.txt File2.txt File3.txt

Or by using wildcards.

Wildcards are special symbols or characters that take the place of characters or words.
For example to encrypt or decrypt every text file, in your current directory, that has the word “file” in its name type the following:

Cipher /e File*.txt

Apart from encrypting/decrypting every text file, you can even use a wildcard to decrypt every file and folder in your current directory.

Cipher /e *

To encrypt/decrypt every file of a different directory type the location of the directory followed by a backwards slash and the asterisk wildcard. 

Cipher /e "C:\Users\Desktop\*"

Replace with your computers name.

Make Deleted Data Unrecoverable Using Cipher:​

Apart from encrypting or decrypting files, cipher can be used to wipe/override all your empty space, making deleted data completely unrecoverable.

To do so use cipher with the /w parameter along with the name of the drive you want to overwrite.

Cipher /wC:\
How to Encrypt/Decrypt Files - Using the Command Line (Cipher, CMD)

Keep in mind that this operation will take quite a long time to complete, to cancel use Control + C.

Its recommended that you close every other application when wiping data so that cipher can overwrite as much data as possible.

You can also wipe the deleted data of a specific directory. For example:

Cipher /wC:\Users\\Desktop

Replace with your computers name.

Useful Parameters & Options:​

  •  /e    Encrypts files and folders.
  •  /d    Decrypts files and folders.
  •  /w   Stands for Wipe. Overrides empty space on a drive or a directory.
  •  /s    Performs the specified operation on a folder recursively.
  •  /f     Stands for force. Performs the specified operation on every selected file including any files that have already been  encrypted/decrypted.
  •  /q    Reports only essential information.
  •  /h    Displays and operates on files with the hidden or system attributes.
  •  /k    Creates a new file encryption key for the current user.

Usage Examples:

Check whether a file is encrypted.

Cipher File.txt

Encrypt a file.

Cipher /e File.txt

Decrypt a file.

Cipher /d File.txt

Decrypt a file named My File that’s located at the desktop directory. Replace with your computers name.

Cipher /e "C:\Users\\Desktop\My File.txt"

Encrypt the a folder along with every item within it.

Cipher /e /s:Folder

Decrypt every text file in the current directory.

Cipher /d *.txt

Overwrite all the empty data on the C drive.

Cipher /wC:\

Overwrite all the empty data on the desktop directory.Replace with your computers name.

Cipher /w"C:\Users\\Desktop\*"


  • Cipher can be used to securely and fully encrypt and decrypt files or directories as well as wipe or overwrite deleted data.
  • Use the Cipher command with either the /e or /d parameters along with the name of your file or folder to encrypt or decrypt it.
  • Use wildcards to encrypt/decrypt many files or folders at once.
  • Use the /w parameter along with the name of your drive to completely overwrite any deleted data.

That's It!

You now know how to encrypt or decrypt your files  and directories directly from the command prompt.

If you liked this short guide take a look at a few of our other posts related to the windows command line, or if you really liked it consider enrolling in our video course where you will learn the ins and outs of the Windows command Line.

Dont Stop Learning!

Windows Command Line Course!

This course has everything you need to start learning about the windows command line along with batch scripting.

Read More:

Any Questions? Ask them Below:

Leave a Reply

Your email address will not be published.

Take Your Skills to the next level!
Become one of our beloved students by enrolling into one of our courses. Get started now!


Take A Look At Our Command Line Course!

Need Help?

There's an easier way!


You are now officially on your way to becoming a genius!