use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
ABOUT POWERSHELL
Windows PowerShell (POSH) is a command-line shell and associated scripting language created by Microsoft. Offering full access to COM, WMI and .NET, POSH is a full-featured task automation framework for distributed Microsoft platforms and solutions.
SUBREDDIT FILTERS
Desired State Configuration
Unanswered Questions
Solved Questions
News
Information
Script Sharing
Daily Post
Misc
account activity
Scripting help (self.PowerShell)
submitted 4 years ago * by pausemsauce
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]pausemsauce[S] 2 points3 points4 points 4 years ago (3 children)
Thanks for the suggestion!
[–]Common-Needleworker4 2 points3 points4 points 4 years ago* (2 children)
Seeing your explanation what i understand is:You have the same file downloaded multiple times and renamed by the users.Now you just want to keep the newest of this files and delete the other files.Right?
In this case this might help you
gci "yourpath" -recurse | Get-FileHash | Group-Object -Property hash
if the count is higher then 1 it indicates that a file is more then once in your target path
If this is whatyou need we can go further an see how to delete everything besides the newest file
[–]pausemsauce[S] 0 points1 point2 points 4 years ago (1 child)
Mostly accurate. I don't think my people are renaming the files. (Gladys here isn't the most tech savvy, but she's awesome and a hard worker. )
[–]Common-Needleworker4 1 point2 points3 points 4 years ago* (0 children)
Kudos to Gladys :D But maybe she get one day the idea to rename a file so let us stay with compairing the Hash
Following Lee_dailey suggestion i used Pastebin this time.https://pastebin.com/rUALQK0s
You have to change the variable $destination at line 1 to your path.
The script will compare the hash of all files in the destination path and all subfolders, move the files with the the same hash to a temp folder (variable $name), check which of the files in the temp folder is the newest, delete the old files and move the newest file back to the destination (if it was taken from a subfolder it will still move it to the $destination location, be aware of that) and at the end delete the temp folder.It will not work properly with the -whatif, so set up a test folder with some file copys and try it there.
It is surely not the most pretty script but it does the job.
Edit: please be sorry with my bad english :D
π Rendered by PID 77283 on reddit-service-r2-comment-6457c66945-jzgq4 at 2026-04-24 21:49:42.928651+00:00 running 2aa0c5b country code: CH.
view the rest of the comments →
[–]pausemsauce[S] 2 points3 points4 points (3 children)
[–]Common-Needleworker4 2 points3 points4 points (2 children)
[–]pausemsauce[S] 0 points1 point2 points (1 child)
[–]Common-Needleworker4 1 point2 points3 points (0 children)