If there are a lot of duplicate files on your Windows PC, you may want to get rid of them. Unnecessary duplicate files waste space and can make file management harder. Windows doesn’t have a feature to directly find and remove them. But Windows’ CMD can help users with this task. This article mainly talks about how to find duplicate files in Windows 10 using CMD successfully.
Windows’ Command Prompt (also known as CMD) is a command shell, an app that allows users to directly communicate with the operating system. With it, users can use commands to perform various tasks, such as finding duplicate files by hash.
PowerShell, which is the advanced version of CMD, replaces CMD in Windows 10 and later, but CMD is still available.
If you have done some searching, you may find that the “dir /s /b *.extension” command (for example, “dir /s /b *.jpg”) is said to be able to find a certain type of duplicate files (for example, duplicate JPG files). However, according to my tests, this command only lists all files of a certain extension on your PC or in a certain directory. It doesn’t identify duplicate files.
The steps below will show you how to successfully find duplicate files in Windows 10 and Windows 11 using CMD.
1. On your Windows computer, type PowerShell in the search box on the taskbar.
2. Open PowerShell.
3. Set the current location to the folder in which you want to delete duplicate files by typing the following command. Replace C:\Users\Administrator\Pictures with the folder of your choice.
set-location –path C:\Users\Administrator\Pictures
4. Press the Enter key.
5. To compute the hash value for the files in the chosen folder with the SHA-256 hashing algorithm, use the following commands. Replace C:\Users\Administrator\Pictures with the chosen folder.
ls "C:\Users\Administrator\Pictures" -recurse | get-filehash | group -property hash | where { $_.count -gt 1 } | % { $_.group } | Out-File -FilePath "C:\Users\Administrator\Desktop\Duplicates.txt"
6. Press the Enter key. The time it takes depends on the number of files. When the process is done, open the Duplicates.txt file.
7. The text file displays the hash value and path of every file of the chosen folder. If two or more files have the same hash value, then they can be a group of duplicates.
The Out-File cmdlet (typed in step 5) creates the Duplicates.txt file in the specified path. If you see the “cannot be read” error after pressing Enter in step 6, then try changing the path to a different location, somewhere other than the folder where you search for duplicate files.
After you get the text file that displays the duplicate files found by CMD, you can manually delete duplicate files. For each group of duplicate files, use a file’s path to locate it in File Explore, and delete the file if you don’t need it anymore. Keep one file in each group and delete the rest.
If you want, you can use commands to automatically remove duplicate files by entering the following commands. Replace C:\Users\Administrator\Pictures with your chosen folder.
ls "C:\Users\Administrator\Pictures" -recurse | get-filehash | group -property hash | where { $_.count -gt 1 } | % { $_.group | select -skip 1 } | del
Note: Using these commands doesn’t allow you to decide which files to delete and will remove duplicate files by deleting them permanently, which can be a bit risky.
Compared to using CMD, there is an easier method, which provides the following benefits.
The best way to get rid of duplicate files in Windows is to use duplicate file finder and remover software Cisdem Duplicate Finder. It’s easy to use, powerful and reliable.
Cisdem Duplicate Finder main features:
1. Download and install Cisdem Duplicate Finder on your Windows PC. Open it.
2. To scan one or multiple folders for duplicate files, drag it or them into the software. Or, you can add locations by clicking the plus icon.
3. Click Scan.
4. Once the scan is done, the All tab will display all the duplicate files that have been found. Sort, preview and view them as you like.
5. The software already automatically selects duplicate files for mass deletion. If you want, you can adjust the selection by choosing a selection rule or by hand.
6. Click Delete in the bottom left corner to clean up the selected unwanted duplicate files on your Windows PC.
Tip: In step 2, if you want, you can do some customization by going to Settings . For example, you can set the software to ignore certain folders and files when it scans for duplicate files.
Cleaning duplicate files can free up storage space and help you manage files more easily. This article shows you how to find and delete duplicate files in Windows 10 using CMD. To get the job done easily, reliably and efficiently, it’s recommended to use dedicated software. Get rid of useless duplicates and enjoy a better PC experience.
Rosa has worked in Mac software industry for more than eight years. She believes that the purpose of software is to make life better and work more productively. In addition to writing, Rosa is also an avid runner.
Bernd Sucher
Thank you for writing this useful article. it really found a lot of duplicate files on my pc. now my computer speeds up. thanks!