Useful Commands To Manage Files And Folders Using Command Prompt

Useful Commands To Manage Files And Folders Using Command Prompt

Share it

This article lists the various commands you can use to manage files and folders through Command line in Windows 11/10. Although many users prefer to use a graphical user interface to manage files for a hassle-free experience, some also use the command line interface to perform file management tasks. In any case, it is always better to know about alternative solutions to perform a task.

In this guide, I will create a list of useful commands that you can use for managing files or folders on your Windows 10 PC. To perform a specific task on files or folders, there is a dedicated command that you need to enter CMD. Let’s check out these commands!


Commands to manage files and folders via CMD

Here are the commands you need to know to manage files and folders using Command Prompt in Windows 11/10:

1]Create file or folder in CMD


To create a folder, type the folder name along with the location where you want to create the folder. Here is the command :


For instance;

mkdir C:UsersKOMALDocumentsTWC

To create a file of a specific size (in bytes), use the command below:

fsutil file createnew file.txt 4000

Instead of file.txt, enter the name of the file with its extension and full path. And, 4000 is the size of the file in bytes.

Related: How to create multiple folders using Command Prompt and PowerShell.

2]Delete files or folder in CMD

You can delete a folder using the command below:


To delete a file, the command is:

del ""


If you want to delete all files in the current folder, enter the command:

del *

To delete only files with a specific extension, for example png, use the command:

del *.png

If you want to delete files with a particular string in their filename, for example xyz, you can use the command below:

del *xyz*

3]Search for files in a particular folder

cd ""

Now you can find files older than n days in a specific folder using the command below:

forfiles /s /m *.* /d -n /c "cmd /c echo @file

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 sizeuse the command:

forfiles /S /M * /C "cmd /c if @fsize GEQ 3741824 echo @path"

In the above command, 3741824 is the file size to search for files larger than this size.

Lily: Managing Files and Folders in Windows 11 – Tips and 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 file extension of all images to JPG, you can use below command:

ren *.* *.jpg

5]Get file creation time and date


To check the creation time and date of a specific file, use the command:

dir /T:C filename

6]Search for a string in a file

To find all lines containing a particular string in a file, you can use the command:

findstr string file-name

For example, to display all lines with “twc” in a text file, you would enter the command:

findstr twc twc.txt


Remember that the above command is case sensitive.

To search for phrases with any specified string, use a command such as:

findstr /C:"string1 string2 string3..." filename

7]Check all hidden files in a folder

Use the command below to get a list of hidden files in a directory:

dir /A:H /B

8]Compress a file in CMD


The command to zip a file into a folder is:

compact /c filename

9]Hide/Show file via CMD


To hide a file, the command used is:

attrib + h filename

You can view the file again using the command:

attrib -h filename

10]Set/Disable read-only attribute of a file


To make a file read-only, the command is:

attrib +R filename

If you want to remove the read-only attribute from a file, the command is:

attrib -R filename

11]Command to rename a file/folder


rename oldfilename.pdf newfilename.pdf

12]Read file contents in CMD


You can read the contents of the text file in CMD using the command below:

more filename

13]Open a file in the 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 drive G, use the command below:

move TWC12.pdf G:TWC

Command to move all files with a specific extension:

move *.png G:TWC


To move files starting with a particular letter, say A, the command is:

move A* G:TWC


Similarly, you can move a folder using a command like below:

move foldername 

For instance:

move TWC1 G:TWC

15]Command to copy files


You can copy files from one location to another using the command:

copy Sourcefolder DestinationFolder

Hope this article helps you learn some useful commands to manage files and folders via command line in Windows 11/10.

Useful commands to manage files and folders via CMD in Windows 10

#Commands #Manage #Files #Folders #Command #Prompt

Share it