Added beat saber cleanup script.

master
parent d2145d42c4
commit 38cbc2bfae

@ -9,6 +9,9 @@ This is a script that I created to zip up my Program Files folders on my C: driv
This script will convert your HEIC files (a format Apple saves photos with) to JPGs. Flip saveasjpg at the top to save as PNG instead. This will result in much larger file sizes. Set keeporiginals to 0 to delete the HEIC files after they're converted. The HEIC files are saved kept around by default. For best results set this up as a cron job.
\* Requires the ImageMagick CLI software to be installed with HEIC support. There are links at the top of the script to do this.
**cleanupBeatSaberSongs.sh**
I wrote this script because I was tired of using the excuse that the folder names are jibberish (98e299036de1688c3f60cda87728ee3c29691888 for example) to not clean up my custom song library. This script goes through all the folders that are 40 characters long (didn't check for only hexadecimal characters so be warned ye ol 40 character song titles), extracts information from their info.dat files (in 2 ways funny enough), and renames the folders to the actual song names with the artist and mapper separated by hyphens. This way if you happen to have a song mapped by different people they don't get overwritten.
**terminalTweaks.txt**
This isn't so much a script as some small quality of life improvements I've made to my WSL Ubuntu 20.04 systems and Ubuntu 20.04 server. Add whichever you like to the end of your .profile and use 'source ~/.profile' to load it immediately.

@ -0,0 +1,49 @@
#!/bin/bash
# Edit the first line with the path to your Beat Saber folder
beatsaberroot='/mnt/a/SteamLibrary/steamapps/common/Beat Saber'
# Leave this one be
customsongpath='Beat Saber_Data/CustomLevels'
# These characters are not allowed in filenames (per Windows)
# and I also removed spaces to make it friendlier to work with
# (this is also a cheat to pull the strings from json without quotes)
badchars='" ,\\\/\:\*\?<>\|'
# Folder name = 40 hexadecimal characters
# ${#foldername} -eq 40
# Not a perfect looping function as it'll loop over the permissions separately but it works
for line in `ls -l "${beatsaberroot}/${customsongpath}"`; do
if [[ ${#line} -eq 40 ]]; then
folder="$line"
fulldir="${beatsaberroot}/${customsongpath}/${folder}"
# Some of my info.dat files are one big json string and my logic below dumps
# 2.0.0_songName-2.0.0_songName-2.0.0_songName insead of the actual info...
infolen=`wc -l "$fulldir/Info.dat" | cut -d' ' -f1`
# Set our variables outside the if so they're usable at the end
song='';artist='';mapper=''
if [[ $infolen -gt 0 ]]; then
# For the easy info.dat files just grab their information
song=`grep _songName "$fulldir/Info.dat" | cut -d: -f2 | sed "s/[$badchars]//g"`
artist=`grep _songAuthorName "$fulldir/Info.dat" | cut -d: -f2 | sed "s/[$badchars]//g"`
mapper=`grep _levelAuthorName "$fulldir/Info.dat" | cut -d: -f2 | sed "s/[$badchars]//g"`
#mv "${beatsaberroot}/${customsongpath}/${folder}" "$song-$artist-$mapper"
else
#tput setaf 1
# -f2 = Song name
# -f4 = Artist
# -f5 = Mapper
song=`cat "$fulldir/info.dat" | cut -d, -f2 | cut -d: -f2 | sed "s/[$badchars]//g"`
artist=`cat "$fulldir/info.dat" | cut -d, -f4 | cut -d: -f2 | sed "s/[$badchars]//g"`
mapper=`cat "$fulldir/info.dat" | cut -d, -f5 | cut -d: -f2 | sed "s/[$badchars]//g"`
fi
mv "$fulldir" "${beatsaberroot}/${customsongpath}/$song-$artist-$mapper" 2>/dev/null
[ $? -eq 0 ] && tput setaf 2 || tput setaf 1
echo "${folder} is really $song-$artist-$mapper"
tput sgr0
fi
done
echo "\nRed means the folder could not be renamed (destination name already exists?) and green means everything should be good!"
Loading…
Cancel
Save