Advertisement
Combreal

OSUMapsCleanup.ps1

Aug 11th, 2024
348
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <#
  2.     .DESCRIPTION
  3.     This script deletes every maps that are not of the specified difficulty level.
  4.     Check https://osu.ppy.sh/wiki/en/Beatmap/Difficulty to get the list of difficulty levels.
  5.  
  6.     Set the Songs folder path via $songsPath.
  7.     And the desired level of difficulty via $difficultyRating.
  8.  
  9.     Depending on the Songs folder path you might have to run this script as Administrator.
  10. #>
  11.  
  12. $songsPath = "D:\Osu!\Songs"
  13. $difficultyRating = "Insane"
  14.  
  15. $mapsList = @()
  16. $mapsPath = (Get-ChildItem -Directory -Path $songsPath).FullName
  17.  
  18. Foreach ($mapPath in $mapsPath) {
  19.     $mapNames = (Get-ChildItem -Path $mapPath -Filter "*.osu").FullName
  20.     Foreach ($mapName in $mapNames) {
  21.         If ($mapName -Like "*$difficultyRating*") {
  22.             $mapsList += $mapPath
  23.             Continue
  24.         }
  25.     }
  26. }
  27.  
  28. Foreach ($mapPath in $mapsPath) {
  29.     If ($mapsList -notcontains $mapPath) {
  30.         Remove-Item -Recurse -Force -Path $mapPath
  31.     }
  32.     Else {
  33.         $mapNames = (Get-ChildItem -Path $mapPath -Filter "*.osu").FullName
  34.         Foreach ($mapName in $mapNames) {
  35.             If ($mapName -NotLike "*$difficultyRating*") {
  36.                 $mapName = $mapName.Insert($($mapName.IndexOf("[")), "````")
  37.                 $mapName = $mapName.Insert($($mapName.IndexOf("]")), "````")
  38.                 Remove-Item -Force -Path "$mapName"
  39.             }
  40.         }
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement