Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import zipfile
- # Define the path to the mods folder and the target file path
- mods_folder = r"C:\Users\***\AppData\Roaming\PrismLauncher\instances\1.21\.minecraft\mods"
- target_path = "data\\c\\tags\\item\\"
- target_file = "coal.json"
- # List to store the names of .jar files containing the target file
- found_jar_files = []
- # Iterate over all .jar files in the mods folder
- for root, dirs, files in os.walk(mods_folder):
- for file in files:
- if file.endswith(".jar"):
- jar_path = os.path.join(root, file)
- try:
- # Open the .jar file as a zip archive
- with zipfile.ZipFile(jar_path, 'r') as jar:
- # Check if the target path and file exists in the .jar archive
- for entry in jar.namelist():
- # Check if the entry matches the target path and file
- if entry == f"{target_path}{target_file}":
- print(f"Found '{target_file}' in: {jar_path}")
- found_jar_files.append(jar_path)
- break # Stop checking further entries in this .jar
- except zipfile.BadZipFile:
- print(f"Error: {jar_path} is not a valid .jar file.")
- # Print results
- if found_jar_files:
- print(f"\nThe following .jar files contain '{target_file}':")
- for jar_file in found_jar_files:
- print(jar_file)
- else:
- print(f"No '{target_file}' found in any .jar files in the folder: {mods_folder}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement