Skip to content

Instantly share code, notes, and snippets.

@Cyphs
Last active March 9, 2025 11:59
Show Gist options
  • Save Cyphs/f5316b8970e21481f98ec2f1ebadb771 to your computer and use it in GitHub Desktop.
Save Cyphs/f5316b8970e21481f98ec2f1ebadb771 to your computer and use it in GitHub Desktop.
Python script to copy downloaded CurseForge Mods for Hogwarts Legacy from the Documents folder to destination folder with the naming structure that the game expects. Change the destination_path before running. Only useful for debug purposes.
import os
import shutil
# Get the path to the user's Documents folder
documents_folder = os.path.expanduser('~/Documents')
# Define source and destination paths
source_path = os.path.join(documents_folder, 'Hogwarts Legacy', 'Mods', '87986')
destination_path = r'E:\SteamLibrary\steamapps\common\Hogwarts Legacy\Phoenix\Mods'
# Function to get the name of the .uplugin file in a folder
def get_uplugin_name(folder_path):
for filename in os.listdir(folder_path):
if filename.endswith('.uplugin'):
return filename[:-8] # Remove the .uplugin extension
return None
# Function to create a unique folder name if the desired name already exists
def get_unique_folder_name(base_name, path):
counter = 1
new_name = base_name
while os.path.exists(os.path.join(path, new_name)):
new_name = f"{base_name}_{counter}"
counter += 1
return new_name
# Iterate through each folder in the source path
for folder_name in os.listdir(source_path):
folder_path = os.path.join(source_path, folder_name)
# Check if it's a directory
if os.path.isdir(folder_path):
uplugin_name = get_uplugin_name(folder_path)
if uplugin_name:
# Construct the new folder name and path
new_folder_name = get_unique_folder_name(uplugin_name, destination_path)
new_folder_path = os.path.join(destination_path, new_folder_name)
# Copy the folder and its contents to the destination with the new name
try:
shutil.copytree(folder_path, new_folder_path)
print(f"Folder {folder_name} renamed to {new_folder_name} and copied to {destination_path}")
except Exception as e:
print(f"Error copying folder {folder_name}: {e}")
else:
print(f"No .uplugin file found in folder {folder_name}. Skipping...")
@Cyphs
Copy link
Author

Cyphs commented Mar 9, 2025

It’s not useful for everyone. It’s just something I attempted when I tried to copy all 351 untrimmed Mods to the game folder after it crashed and didn’t copy normally. It’s not very useful since the Mods need to be enabled, applied, and loaded on a certain Mod Save in-game to take effect on the SaveGameList.sav and Mod Save’s .sav files.

However, at time of posting, it seems like the Mods are temporarily loaded when compiling shaders during a normal launch of the game, even if you don’t enable or use a Mod Save yet or have even setup the in-game mods. So this could be useful for debug purposes in rare circumstances, like downloading the Mods on the Epic Games Store version of the game and copying to the Steam version of the game.

More info: https://gist.github.com/Cyphs/adbee4788b4649d2587977cd402aef06?permalink_comment_id=5473279#gistcomment-5473279

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