The directory layout from downloaded mods is not always the same, most allow you to directly copy into root KSP2 folder and they will go into /BepInEx/plugins or similar, but a few mods will just have a folder with the mod name or a plugins directory.
Potential Solutions:
Potentially use regex to get the first folder name and make a best guess as to where to put it depending on the name of the first directory. For example, if the first directory we see is plugins we know to extract it directly into KSP2/BepInEx/ where it will overwrite the existing folder, whereas if the first directory we see from unzip is something like atmoswitch then it most likely has to go into KSP2/BepInEx/plugins/.
Description
The directory layout from downloaded mods is not always the same, most allow you to directly copy into root KSP2 folder and they will go into
/BepInEx/plugins
or similar, but a few mods will just have a folder with the mod name or aplugins
directory.Potential Solutions:
Potentially use regex to get the first folder name and make a best guess as to where to put it depending on the name of the first directory. For example, if the first directory we see is
plugins
we know to extract it directly intoKSP2/BepInEx/
where it will overwrite the existing folder, whereas if the first directory we see from unzip is something likeatmoswitch
then it most likely has to go intoKSP2/BepInEx/plugins/
.