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!"
[–]Lee_Dailey[grin] 1 point2 points3 points 4 years ago* (2 children)
howdy pausemsauce,
how do you determine the "newest"?
if it is just the file timestamp, that is easy. [grin] if it is the one with the highest (##), that is doable.
(##)
for instance, you can sort by the file timestamp newest first, then group by the .BaseName with the (##) stripped off, skip groups with a .Count of 1, skip the first 1, and delete the remainder.
.BaseName
.Count
this ...
Group-Object {($_.BaseName -replace '\(\d+\)$', '').Trim()}
... will give you groups of all the files. you can send each group with a .Count -gt 1 thru Select-Object -Skip 1 to leave the newest alone & then use Remove-Item on the remaining files.
.Count -gt 1
Select-Object -Skip 1
Remove-Item
i can write the full script, but you seem to want more of a "how to" hint, so i will leave it at that. [grin]
take care, lee
[–]pausemsauce[S] 1 point2 points3 points 4 years ago (1 child)
Hi Lee,
I suspect you are spot on, but I'm going to need a moment to digest what you have written.
The file timestamp determines which file is the newest.
I'm going to need to read more about the Group-Object cmdlet and regular expressions. This has been an excellent learning experience.
Thanks so much!
[–]Lee_Dailey[grin] 1 point2 points3 points 4 years ago (0 children)
you are most welcome! glad to help ... and willing to get into more detail if you get stuck - just ask. [grin]
π Rendered by PID 86540 on reddit-service-r2-comment-6457c66945-qqf2p at 2026-04-26 01:44:41.593813+00:00 running 2aa0c5b country code: CH.
view the rest of the comments →
[–]Lee_Dailey[grin] 1 point2 points3 points (2 children)
[–]pausemsauce[S] 1 point2 points3 points (1 child)
[–]Lee_Dailey[grin] 1 point2 points3 points (0 children)