Beginner - Create a folder cleanup script

<p class=“s1w8oh2o-10 bQeEFC”>Hi,</p>
<p class=“s1w8oh2o-10 bQeEFC”>I am trying to create a folder cleanup script but am having some issue, what I am trying to achieve is we have a folder full of files that will have a revision number as the last character, such as below</p>
<p class=“s1w8oh2o-10 bQeEFC”>1111-1111A</p>
1111-1111B

1111-1111C

2222-2222A

2222-2222B
<p class=“s1w8oh2o-10 bQeEFC”>xxxx-xxxxB</p>
<p class=“s1w8oh2o-10 bQeEFC”>xxxx-xxxxC</p>
<p class=“s1w8oh2o-10 bQeEFC”>What I am trying to do is move to another folder the lower file revision from the folder leaving only the latest revision in the folder (highest alpha character).</p>
<p class=“s1w8oh2o-10 bQeEFC”>Any suggestions as to how to go about this.</p>

Below are some discussiongs and blog posts for the same which will help you.

https://stackoverflow.com/questions/2704748/folder-cleanup-with-powershell

Here is one that I made to clean up temp folders of all kinds of data that people move in and out of environments. It will delete everything that was accessed prior to whatever amount of days, and also places a warning file letting users know their data is not secure. I set this as a scheduled task on the file servers.

$howOld = (Get-Date).AddDays(-30)
$path = "A:\Path\To\Folder"

# Delete files older than the $howOld bits, based on the LastAccessTime attribute.
Get-ChildItem -Path $path -Recurse -Force | Where-Object { !$_.PSIsContainer -and $_.LastAccessTime -lt $howOld } | Remove-Item -Force
# Delete any empty directories left behind after deleting the old files.
Get-ChildItem -Path $path -Recurse -Force | Where-Object { $_.PSIsContainer -and (Get-ChildItem -Path $_.FullName -Recurse -Force | Where-Object { !$_.PSIsContainer }) -eq $null } | Remove-Item -Force -Recurse
# Create a file that warns users of the delete rules
New-Item -ItemType file -path $path\_This-Data-Will-Be-Deleted_ -value "All content in this directory will be deleted after 30 days"