Last active
December 9, 2023 20:28
-
-
Save t0mtee/afbe91d62ffaf20a34c1bcbf9e8c0208 to your computer and use it in GitHub Desktop.
Lenny's Mod Loader Linux Script. Put it in your lml folder. (written by ChatGPT)
This file contains hidden or 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
#!/bin/bash | |
# Erase lines between <Mods> and </Mods> excluding the tags | |
sed -i '/<Mods>/,/<\/Mods>/ { /<Mods>/b; /<\/Mods>/b; d; }' mods.xml | |
# Erase lines between <LoadOrder> and </LoadOrder> excluding the tags | |
sed -i '/<LoadOrder>/,/<\/LoadOrder>/ { /<LoadOrder>/b; /<\/LoadOrder>/b; d; }' mods.xml | |
# Find all install.xml files in subfolders, sort them alphabetically based on parent directory's name, and process each one | |
find . -name 'install.xml' | sort -t/ -k2,2 -r | while read -r install_xml; do | |
# Get the directory of the install.xml file | |
LOCATION=$(dirname "$install_xml") | |
# Trim to cut out all folders above the script | |
LOCATION=$(realpath --relative-to=. "$LOCATION") | |
# Get the value between <name> and </name> | |
NAME=$(grep -oP '(?<=<Name>).*?(?=</Name>)' "$install_xml") | |
# Add to mods.xml at line 4 | |
sed -i "4i\\ | |
<Mod folder=\"$LOCATION\">\n <Name>$NAME</Name>\n <Enabled>true</Enabled>\n <Overwrite>false</Overwrite>\n <DisabledGroups />\n </Mod>" mods.xml | |
# Add under the line containing <LoadOrder> | |
sed -i "/<LoadOrder>/a\ <Mod>$LOCATION</Mod>" mods.xml | |
done | |
rm patterns.dat |
This file contains hidden or 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
<?xml version="1.0" encoding="utf-8"?> | |
<ModsManager> | |
<Mods> | |
</Mods> | |
<LoadOrder> | |
</LoadOrder> | |
</ModsManager> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment