Skip to content

Instantly share code, notes, and snippets.

@JohnSmith25
Last active Sep 9, 2022
Embed
What would you like to do?
A OpenMW mod file mover to a different directory.
#-------------------------------------------------------------------------------
#A script to export the mod to a different directory
#-------------------------------------------------------------------------------
#Some initalization to make this script to work.
shopt -s expand_aliases
#Usage:
#Edit the settings first so that it matches your mod and your directory path
#Then run the bash script.
#Installation directory:
#Linux: ~/.local/share/openmw/data/
#TODO: Fix a minor bug where rm would complain it cannot remove a non existing folder
#The Directory name of the mod
#Change the settings here
MODNAME=CrossbowMod #The mod name
MODINSTALLNAME="/[MYMOD] Crossbow Mod" #The installed mod directory name
MODINSTALLPATH="/home/kruzchev/Dokumente/Programme/Mods/Morrowind_MO2/mods" #The installed mod path
#Internal settings
MODNAMEADDON=$MODNAME.omwaddon #The mod full name
MESHESSDIR=./Meshes/$MODNAME #Meshes Directory
TEXTURESDIR=./Textures/$MODNAME #Textures Directory
ICONDIR=./Icons/$MODNAME #Icon Directory
#The initalized directory path
MESHESDIR_NORMAL+="${MODINSTALLPATH}${MODINSTALLNAME}/Meshes/"
TEXTURESDIR_NORMAL+="${MODINSTALLPATH}${MODINSTALLNAME}/Textures/"
ICONDIR_NORMAL+="${MODINSTALLPATH}${MODINSTALLNAME}/Icons/"
MODPATH_NORMAL+="${MODINSTALLPATH}${MODINSTALLNAME}"
echo "[OpenMW Mod exporter starting up]"
echo "..."
echo ""
#Rename the OpenMW mod file to MO2 loadable file
if test -f "./$MODNAME.omwaddon"; then
echo "<Renaming File>"
mv "${MODNAMEADDON}" "${MODNAME}.esp"
fi
#Remove the folders first
echo ""
echo "<Removing old files>"
if test "${MESHESDIR_NORMAL}"; then
echo "<Removing meshes>"
rm -rdv "${MESHESDIR_NORMAL}"
fi
if test "${TEXTURESDIR_NORMAL}"; then
echo "<Removing textures>"
rm -rdv "${TEXTURESDIR_NORMAL}"
fi
if test "${ICONDIR_NORMAL}"; then
echo "<Removing sounds>"
rm -rdv "${ICONDIR_NORMAL}"
fi
#Copy the folders and files back
echo ""
echo "<Copying files>"
echo "<Copying mod file>"
cp -v "${MODNAME}.esp" "${MODPATH_NORMAL}"
if test "${MESHESSDIR}"; then
echo "<Copying mesh folder>"
cp -avr "${MESHESSDIR}" "${MESHESDIR_NORMAL}"
fi
if test "${TEXTURESDIR}"; then
echo "<Copying textures folder>"
cp -avr "${TEXTURESDIR}" "${TEXTURESDIR_NORMAL}"
fi
if test "${ICONDIR}"; then
echo "<Copying icons folder>"
cp -avr "${ICONDIR}" "${ICONDIR_NORMAL}"
fi
#Done
echo ""
echo "All done. Enjoy your mod!"
@JohnSmith25
Copy link
Author

JohnSmith25 commented Sep 9, 2022

Forget to add the MODNAME.omwaddon file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment