Is it possible to delete 500,000 files in a folder at once without manually deleting?
Go to solution
Solved by Oshino Shinobu,
Wrote a quick powershell script to do this.
It will remove anything in Folder A that does not match in Folder B. It will not remove anything from folder B. Obviously, replace the paths with the ones you require.
$FolderA = Get-childitem "D:\test\Folder1" $FolderB = Get-childitem "D:\test\Folder2" $FilestoRemove = Compare-Object $FolderA $FolderB -Property BaseName -PassThru | Where-Object {$_.SideIndicator -eq '<='} foreach ($file in $FilestoRemove) { Remove-Item -Path $file.FullName }
I'd advise testing this first on some test folders to make sure it does what you want it to. Make a backup before using it if you can.
Disclaimer here: I won't be held responsible if you use the script incorrectly or it otherwise removes files not as you intended.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now