Combreal icon

OSUMapsCleanup.ps1

Combreal | PRO | 08/11/24 12:10:34 PM UTC | 0 ⭐ | 8214 👁️ | Never ⏰ | []
PowerShell |

1.38 KB

|

None

|

0 👍

/

0 👎

<# 
    .DESCRIPTION
    This script deletes every maps that are not of the specified difficulty level.
    Check https://osu.ppy.sh/wiki/en/Beatmap/Difficulty to get the list of difficulty levels.
 
    Set the Songs folder path via $songsPath.
    And the desired level of difficulty via $difficultyRating.
 
    Depending on the Songs folder path you might have to run this script as Administrator.
#>
 
$songsPath = "D:\Osu!\Songs"
$difficultyRating = "Insane"
 
$mapsList = @()
$mapsPath = (Get-ChildItem -Directory -Path $songsPath).FullName
 
Foreach ($mapPath in $mapsPath) {
    $mapNames = (Get-ChildItem -Path $mapPath -Filter "*.osu").FullName
    Foreach ($mapName in $mapNames) {
        If ($mapName -Like "*$difficultyRating*") {
            $mapsList += $mapPath
            Continue
        }
    }
}
 
Foreach ($mapPath in $mapsPath) {
    If ($mapsList -notcontains $mapPath) {
        Remove-Item -Recurse -Force -Path $mapPath
    }
    Else {
        $mapNames = (Get-ChildItem -Path $mapPath -Filter "*.osu").FullName
        Foreach ($mapName in $mapNames) {
            If ($mapName -NotLike "*$difficultyRating*") {
                $mapName = $mapName.Insert($($mapName.IndexOf("[")), "````")
                $mapName = $mapName.Insert($($mapName.IndexOf("]")), "````")
                Remove-Item -Force -Path "$mapName"
            }
        }
    }
}

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎