Eight useful tips on how to manage files in Windows' command prompt.
Command Prompt is easily one of the most underused Windows features, as far as regular end users are concerned. The UI is from the old DOS that predates Windows and many people simply don’t know what to do with a black window of nothingness.
This is a shame since Command Prompt is among the most powerful tools in Windows. The possibilities are virtually endless, and once you scratch the surface, you’ll be greeted by a ton of opportunities for performing various tasks.
Here we’ll put the focus on file management. There are many ways to manipulate files in Command Prompt and you’ll see some of the most common ones. But before we get into that, let’s start with the basics.
The easiest way to open Command Prompt is by using the Run function. Hit the Windows key + R at the same time and you’ll see a pop-up window. In the Open bar, type cmd and click ok. This will open the main window of Command Prompt.
From here, you can type any commands you want. To make using Command Prompt easier, you’ll want to learn how to use the function key shortcuts. Function keys F1–F9 perform certain actions that often come in handy. Here’s what they are:
Now that you know the basics, let’s take a look at some of the main file management commands.
1. Creating a File
To create a new file in Command Prompt, type the following command:
fsutil file createnew filename.txt 1000
The parameters to keep in mind here are the filename, extension, and size. You can name the file as you wish and create any file type. In this example, the file size would be 1000 KB. By entering the desired value, you’re telling Windows to create the file that requires that much space on your drive.
2. See All Files in a Directory
Command: dir
Typing dir into the Command Prompt will let you see all the files that are currently within the directory you’re in. This can be useful in many situations, especially when you want to see the extensions that can be accessed from the folder.
3. Show All Files Organized by Folders
Command: tree
When you navigate to a directory, just type tree in the Command Prompt and you’ll see all your files within their corresponding folders. This gives you a clear overview of all the files in a directory and make file navigation easy.
4. Change All File Extensions in a Folder
Command: rename
If you need to change the type of all the files within a folder, you can do so in no time in Command Prompt. For example, if you have a folder where all images are in .png, you can change them to .jpeg or any other image type with the rename command.
Just type rename *.png*.jpeg and all your images will have a .jpeg extension.
5. Show Hidden Files
To uncover all hidden files and folders within a directory, use the following command:
dir /A:H /B
You can also do this for the hidden files and folders in a directory’s subfolders with the command below:
dir /s /b /A:DH
If you want to hide a file, you can do so by entering the following:
attrib +s + h file_name
When you do this, the file will be invisible in normal view, even with the Show Hidden Files option. The only way to make the file visible again is to enter the following line:
attrib -s -h file_name
6. Copy and Paste Files
You can copy files from one folder to another by entering the following command:
Xcopy /I Source_folderDestination_folder
If you want to copy all files along with the subfolders, type in:
Xcopy /S /I /E Source_folder Destination_folder
7. Scan Files for Viruses
This is a neat command that everyone should use every once in a while, even if they have a good antivirus software. To do this, you need to run the Command Prompt as administrator, which you can do by right-clicking the shortcut and then clicking Run as administrator.
Once you’ve done this, just type sfc /scannow and all the files inside a directory will be checked for viruses and other corruptions.
8. Wipe an Entire Drive
As you might know, the files you delete by using the regular methods are never gone for good. There are many ways to recover them, even years after the deletion. Using the cipher command is the only way to completely wipe the whole drive. For example, if you want to clean the D drive, type in cipher /w:D:\.
Keep in mind that once you do this, the files are unrecoverable, so only do it if you’re certain that you want to erase all data from a drive.
What you see here are only some of Command Prompt’s numerous file management capabilities. There are many functions that would otherwise be impossible to perform effectively, so learning how to use it can be a very useful skill.
The Command Prompt’s power extends far beyond file management. There’s pretty much no aspect of Windows that you can’t control in Command Prompt. Of course, learning all the codes can take quite some time and effort, but it’s something that can pay off in the long run.