Small bash script to quickly convert OpenMW created mod to a Mod Organizer 2 loadable mod

Questions specific to OpenMW-CS can be asked, and content development related topics can be discussed here
Post Reply
Rosamonde
Posts: 14
Joined: 07 May 2021, 14:04

Small bash script to quickly convert OpenMW created mod to a Mod Organizer 2 loadable mod

Post by Rosamonde »

I quickly threw together a small bash script to automatize the process of manually packing files and renaming the plugin file to something that Mod Organizer 2 can load, its a fairly small script but for my purpose it does it job. Maybe there is some issues with specific mod content organization so that it probably needs to be adapted for it or maybe even converted to Python 3 code instead, I'll have to see. Anyway here it is:

https://gist.github.com/JohnSmith25/8c8 ... d456c733cb

Usage:
Edit the script file and from the first line

Code: Select all

MODNAME=CrossbowMod #The Mod Name
edit the mod name to your mod name if your mod name is for example named as

Code: Select all

PotionSeller
then it should look like as

Code: Select all

MODNAME=PotionSeller #The Mod Name
then you can run this script under your terminal so that you also can see its log output. The end result is a zip file which can be directly loaded into Mod Organizer 2.
User avatar
AnyOldName3
Posts: 2451
Joined: 26 Nov 2015, 03:25

Re: Small bash script to quickly convert OpenMW created mod to a Mod Organizer 2 loadable mod

Post by AnyOldName3 »

If your mod comes as nearly any archive format people are likely to distribute mods as, it's very likely MO2 can install it as-is (although it's likely you'll need to check some checkboxes or move files around as mod authors rarely pack things sensibly - it would be great if people could go through old mods and either rearrange them as basic BAINs when they're simple, or XML FOMODs when they're not). If for whatever reason, you've already got the mod extracted somewhere, you should be able to just copy and paste its directory into MO2's mods directory and it'll get picked up without needing a zip as an intermediate step. I think I'm missing what this script's meant to achieve that can't be done more easily by other means.
AnyOldName3, Master of Shadows
Rosamonde
Posts: 14
Joined: 07 May 2021, 14:04

Re: Small bash script to quickly convert OpenMW created mod to a Mod Organizer 2 loadable mod

Post by Rosamonde »

AnyOldName3 wrote: 22 Aug 2022, 21:03 you should be able to just copy and paste its directory into MO2's mods directory and it'll get picked up without needing a zip as an intermediate step. I think I'm missing what this script's meant to achieve that can't be done more easily by other means.
Did they added now support for .omwaddon on Mod Organizer 2? The version I have doesn't recognizes it and it still requires on my end to manually rename .omwaddon to .esp file format. Also even if I don't have to do the renaming part it still bundles the content of a mod inside a zip file so instead of having to manually handle different folders just to update a content (textures, sounds, models, etc...) it zips them all up in a single file so you only need to replace one file instead of multiple different ones.

I have no idea how you handle mods with Mod Organizer 2 but I think it still has some niche usage if a person works on multiple mods so that it will be easier for him to see the changes directly, at least for me anyway. I thought this script might be useful to others too.

In my end I have so far only 2 mini mods and I am using my script all the time to quickly update the mod in Mod Organizer 2 every time I make changes to it, so that I don't have to manually go through the content folder and copy and paste the changed content folder manually.
User avatar
AnyOldName3
Posts: 2451
Joined: 26 Nov 2015, 03:25

Re: Small bash script to quickly convert OpenMW created mod to a Mod Organizer 2 loadable mod

Post by AnyOldName3 »

The renaming of .omwaddons to .esps is still necessary, but you're doing something wrong if you're handling the meshes/textures/sounds/etc. directories separately. If you just replace the directory that contains all of them, you get the same effect as using the zip.
AnyOldName3, Master of Shadows
Rosamonde
Posts: 14
Joined: 07 May 2021, 14:04

Re: Small bash script to quickly convert OpenMW created mod to a Mod Organizer 2 loadable mod

Post by Rosamonde »

So I don't even have to zip up the files and I can just use the directories as is?
User avatar
AnyOldName3
Posts: 2451
Joined: 26 Nov 2015, 03:25

Re: Small bash script to quickly convert OpenMW created mod to a Mod Organizer 2 loadable mod

Post by AnyOldName3 »

If you right-click on a mod in the left pane in MO2, and choose Open in Explorer, you'll see each mod is in its own directory on its own. You can just add more directories and MO2 will see them as mods.
AnyOldName3, Master of Shadows
Rosamonde
Posts: 14
Joined: 07 May 2021, 14:04

Re: Small bash script to quickly convert OpenMW created mod to a Mod Organizer 2 loadable mod

Post by Rosamonde »

Sorry for my late response, well I have considered your idea now and I made a different bash script, will this one be more useful then? This bash script deletes the directory of the MO2 mods folder and copies back the folder of the OpenMW CS user created mod folder. It should be easily expandable to include other directories too as all you have to do is look up the stuff, copy the variables and rename them accordingly, so if you need one for sounds or animation you just do copy and paste operation. I haven't included those yet because I didn't looked up what their directory name was.

Though there is a small bug where rm would complain that it cannot remove a folder from the target directory but it should be a minor issue, no idea why the test conditions fails on that one.

https://gist.github.com/JohnSmith25/eb6 ... 94578cf375
User avatar
AnyOldName3
Posts: 2451
Joined: 26 Nov 2015, 03:25

Re: Small bash script to quickly convert OpenMW created mod to a Mod Organizer 2 loadable mod

Post by AnyOldName3 »

Any particular reason why you're deleting and copying just the .esp and meshes, textures and icons directories rather than deleting and copying the whole mod directory? I'd have thought you'd have wanted to replace everything, in which case it's simpler to just do that rather than explicitly list things. The only file you might want to keep is MO2's meta.ini for the mod, which could be saved by copying it to temp before doing the deletion, and copying it back after doing the copy.
AnyOldName3, Master of Shadows
Rosamonde
Posts: 14
Joined: 07 May 2021, 14:04

Re: Small bash script to quickly convert OpenMW created mod to a Mod Organizer 2 loadable mod

Post by Rosamonde »

AnyOldName3 wrote: 09 Sep 2022, 18:50 Any particular reason why you're deleting and copying just the .esp and meshes, textures and icons directories rather than deleting and copying the whole mod directory? I'd have thought you'd have wanted to replace everything, in which case it's simpler to just do that rather than explicitly list things. The only file you might want to keep is MO2's meta.ini for the mod, which could be saved by copying it to temp before doing the deletion, and copying it back after doing the copy.
Well I am not familiar with OpenMW-CS editor so I have no idea how I should put all those contents so that the CS editor can still load those assets, that's why I did this bash script as is. If there is somewhere a option to load assets per mod folder instead of per asset/modname folder as I have right now then I could refactor the bash script to make it even more generic.
User avatar
AnyOldName3
Posts: 2451
Joined: 26 Nov 2015, 03:25

Re: Small bash script to quickly convert OpenMW created mod to a Mod Organizer 2 loadable mod

Post by AnyOldName3 »

I'm not entirely sure I understand what you're saying. What I was saying is that it's more convenient and simple to do

Code: Select all

rm -r "${MODPATH_NORMAL}"
cp -ar . "${MODPATH_NORMAL}"
mv "${MODPATH_NORMAL}/${MODNAME}.omwaddon" "${MODPATH_NORMAL}/${MODNAME}.esp"
than to delete and replace each of the directories individually.
AnyOldName3, Master of Shadows
Post Reply