In this guide, I will be creating a list of useful commands that you can use for file or folder management on your Windows 10 PC. To perform a specific task on files or folders, there is a dedicated command that you need to enter in CMD. Let’s check out these commands!
Commands to Manage Files and Folders through CMD
Here are the commands that you should know to manage files and folders using Command Prompt in Windows 11/10:
1] Create a File or Folder in CMD
To create a folder, type the folder name with the location where you want to create the folder. Here is the command: For example; To create a file of a specific size (in bytes), use the below command: In place of file.txt, enter the filename with its extension and full path. And, 4000 is the file size in bytes.
2] Delete Files or Folder in CMD
You can remove a folder using the below command: In order to delete a file, the command is:
If you want to delete all files from the current folder, enter the command: To delete files with a specific extension only, say png, use the command: If you want to delete files with a particular string in their filename, e.g., xyz, you can use the below command:
3] Find Files in a Particular Folder
To find files inside a folder based on different parameters, you first need to navigate to the folder using the command: Now, you can find files older than n days in a specific folder using the below command: Replace -n with the number of days. Like if you want to find files older than 2 days, type -2.
To find files larger than a specific size, use the command: In the above command, 3741824 is the file size to search files greater than this size. Read: Managing Files and Folders in Windows 11 – Tips & Tricks
4] Rename all file extensions present in a folder at once
You can also batch rename file extensions in CMD. Suppose, you want to rename the file extension of all images to JPG, you can use the below command:
5] Get File Creation Time and Date
To check the creation time and date of a specific file, use the command:
6] Check for a string inside a file
To find all lines containing a particular string in a file, you can use the command: For example, to display all lines with “twc” in a text file, you need to enter the command:
Do remember that the above command is case-sensitive. To find sentences with any specified string, use a command like:
7] Check for all Hidden Files in a Folder
Use the below command to get a list of hidden files in a directory:
8] Compress a File in CMD
The command to compress a file in a folder is:
9] Hide/ Unhide a file through CMD
To hide a file, the command used is: You can unhide the file again using the command:
10] Set/ Unset Read-Only attribute to a file
To make a file read-only, the command is: If you want to remove the read-only attribute from a file, the command is:
11] Command to Rename a File/Folder
12] Read File Content in CMD
You can read text file content in CMD using the below command:
13] Open a File in Default Application
You can open a file in its default application by entering a simple command:
14] Move File / Folder to different Location
Suppose you want to move TWC12.pdf file to TWC folder in G drive, use below command: Command to move all files with a specific extension:
To move files starting with a particular letter, say A, command is:
Similarly, you can move a folder using a command like below: For example:
15] Command to Copy Files
You can copy files from one location to another using command: Hope this article helps you learn some useful commands to manage files and folders through the command line in Windows 11/10.