- Run
Split-Songs.ps1
. It will move all of your songs into a directory calledSongsBatch
, with each batch having its own folder. - Once the initial move completes, a function called
Move-OsuBatch
will be defined globally. You can call this repeatedly to:- Delete all files in the Songs directory
- Move all songs from the first batch to the Songs directory
- Launch osu!lazer and import your songs from stable
- Repeat steps 2 and 3 until finished
Last active
May 11, 2021 10:07
-
-
Save ribbanya/d60bfac56c312850992ef2cdf7c58aeb to your computer and use it in GitHub Desktop.
Batch move osu! stable songs into groups for segmented import to lazer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$batchSize = 1000 | |
function global:Move-OsuBatch | |
{ | |
Push-Location "$Env:LOCALAPPDATA/osu!" | |
try | |
{ | |
Remove-Item Songs\* -Confirm -Verbose -Recurse | Tee-Object -Append -FilePath 'Split-Songs.log' | |
$dir = Get-ChildItem -Directory SongsBatch | Sort-Object {[int]$_.Name} | Select-Object -First 1 | |
$children = Get-ChildItem $dir | |
foreach ($child in $children) | |
{ | |
Move-Item -Force -Verbose -LiteralPath $child Songs *>&1 | Tee-Object -Append -FilePath 'Split-Songs.log' | |
} | |
Remove-Item -Verbose $dir *>&1 | Tee-Object -Append -FilePath 'Split-Songs.log' | |
} | |
finally | |
{ | |
Pop-Location | |
} | |
} | |
Push-Location "$Env:LOCALAPPDATA/osu!" | |
try | |
{ | |
$songs = Get-ChildItem Songs | |
$counter = [pscustomobject] @{ Value = 0 } | |
# https://stackoverflow.com/a/26850233/5880994 | |
$groups = $songs | Group-Object -Property { [math]::Floor($counter.Value++ / $batchSize) } | |
foreach ($group in $groups) | |
{ | |
$dir = New-Item "SongsBatch/$($group.Name)" -ItemType Directory -Force | |
foreach ($item in $group.Group) | |
{ | |
Move-Item -Verbose -LiteralPath $item $dir *>&1 | Tee-Object -Append -FilePath 'Split-Songs.log' | |
} | |
} | |
} | |
finally | |
{ | |
Pop-Location | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment