gpt-4-0314· openai
Suzhen/CodeChat
python create a script that gets a base folder given T:\Fivem Related\Alpha…
- User
python create a script that gets a base folder given T:\Fivem Related\Alpha Dev\stream_weapons\metas\addon and then copies all of the weapons.meta files into one folder and just call it weapons1.meta, weapons2.meta etc
- Assistantpython
import os import shutil def find_and_copy_metas(base_folder, output_folder="merged_metas"): os.makedirs(output_folder, exist_ok=True) base_folder = os.path.abspath(base_folder) metas_found = [] file_counter = 1 for root, dirs, files in os.walk(base_folder): for file in files: if file.endswith("weapons.meta"): metas_found.append(os.path.join(root, file)) shutil.copy2(os.path.join(root, file), os.path.join(output_folder, f"weapons{file_counter}.meta")) file_counter += 1 return metas_found if __name__ == "__main__": base_folder = r"T:\Fivem Related\Alpha Dev\stream_weapons\metas\addon" result = find_and_copy_metas(base_folder) print(f"Found and copied {len(result)} metas")