How to remove duplicate Files on Windows via Power Shell

Configurare noua (How To)

Situatie

Duplicate files occupy unnecessary space in your computer hence slowing it down. These files are copies of already existing files on your device. You may have file duplicates of photos, videos, audios, archives, documents, etc.

Solutie

Pasi de urmat

Right-click on the “Start” button, and on the list of features that appear, select “Windows PowerShell (Admin)”

windows powershell windows10

Paste the command below to set the location path to your main drive. Press “Enter” to run the command.

set-location –path C:\

set location

Paste the command below and replace the “search folder” and “location folder” with the actual folders on your computer. Next, press the “Enter” button.

ls “(search folder)” -recurse | get-filehash | group -property hash | where { $_.count -gt 1 } | % { $_.group } | Out-File -FilePath “(location folder)

duplicates command

The above process will take some time to complete (depending on the number of files in the search folder). When it finishes, open the results file (.txt file) to identify the location of the duplicate files and manually delete them.

duplicates txt

You can paste the command below to delete the duplicates automatically. Ensure you replace the “search folder” with your actual folder name.

ls “(search folder)” -recurse | get-filehash | group -property hash | where { $_.count -gt 1 } | % { $_.group | select -skip 1 } | del

delete duplicates

Tip solutie

Permanent

Voteaza

(2 din 8 persoane apreciaza acest articol)

Despre Autor

Leave A Comment?