Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from pathlib import Path, PurePath
- import subprocess, sys
- ARCHIVE2=Path(PurePath("C:\Program Files (x86)\Steam\steamapps\Steam\Fallout 4\Tools\Archive2\Archive2.exe"))
- ALL_BA2=['DLCCoast - Main.ba2','DLCCoast - Textures.ba2','DLCCoast - Voices_en.ba2','DLCNukaWorld - Main.ba2','DLCNukaWorld - Textures.ba2','DLCNukaWorld - Voices_en.ba2','DLCRobot - Main.ba2','DLCRobot - Textures.ba2','DLCRobot - Voices_en.ba2','DLCUltraHighResolution - Textures01.ba2','DLCUltraHighResolution - Textures02.ba2','DLCUltraHighResolution - Textures03.ba2','DLCUltraHighResolution - Textures04.ba2','DLCUltraHighResolution - Textures05.ba2','DLCUltraHighResolution - Textures06.ba2','DLCUltraHighResolution - Textures07.ba2','DLCUltraHighResolution - Textures08.ba2','DLCUltraHighResolution - Textures09.ba2','DLCUltraHighResolution - Textures10.ba2','DLCUltraHighResolution - Textures11.ba2','DLCUltraHighResolution - Textures12.ba2','DLCUltraHighResolution - Textures13.ba2','DLCUltraHighResolution - Textures14.ba2','DLCUltraHighResolution - Textures15.ba2','DLCUltraHighResolution - Textures16.ba2','DLCworkshop01 - Main.ba2','DLCworkshop01 - Textures.ba2','DLCworkshop02 - Main.ba2','DLCworkshop02 - Textures.ba2','DLCworkshop03 - Main.ba2','DLCworkshop03 - Textures.ba2','DLCworkshop03 - Voices_en.ba2','Fallout4 - Animations.ba2','Fallout4 - Interface.ba2','Fallout4 - Materials.ba2','Fallout4 - Meshes.ba2','Fallout4 - MeshesExtra.ba2','Fallout4 - Misc.ba2','Fallout4 - Nvflex.ba2','Fallout4 - Shaders.ba2','Fallout4 - Sounds.ba2','Fallout4 - Startup.ba2','Fallout4 - Textures1.ba2','Fallout4 - Textures2.ba2','Fallout4 - Textures3.ba2','Fallout4 - Textures4.ba2','Fallout4 - Textures5.ba2','Fallout4 - Textures6.ba2','Fallout4 - Textures7.ba2','Fallout4 - Textures8.ba2','Fallout4 - Textures9.ba2','Fallout4 - Voices.ba2']
- if (len(sys.argv) != 4):
- print("Usage: {} SOURCE_DIR WORKING_DIR TOP_DIR".format(__file__))
- sys.exit()
- try:
- source=Path(PurePath(sys.argv[1]))
- tmp=Path(PurePath(sys.argv[2]))
- top=Path(PurePath(sys.argv[3]))
- archive=Path(source, 'ba2_backup')
- print("INFO: source={}".format(source))
- print("INFO: tmp={}".format(tmp))
- if not archive.is_dir():
- archive.mkdir()
- for ba2 in source.iterdir():
- if ba2.name not in ALL_BA2:
- print("WARN: Skipping file {}".format(ba2))
- continue
- print("INFO: Processing file {}".format(ba2))
- working=Path(tmp, ba2.stem)
- if not working.is_dir():
- print("INFO: Making directory {}".format(working))
- working.mkdir()
- command=[str(ARCHIVE2), str(ba2), '-q', '-e={}'.format(working)]
- print('INFO: Executing', command)
- subprocess.call(command)
- print("INFO: Creating backup of {}".format(ba2))
- ba2.replace(Path(archive, ba2.name))
- command=['robocopy', str(top), str(working), '/s', '/xl']
- print('INFO: Executing', command)
- subprocess.call(command)
- command=[str(ARCHIVE2), str(working), '-q', '-c={}'.format(ba2), '-r={}'.format(working), '-compression=None']
- print('INFO: Executing', command)
- subprocess.call(command)
- except:
- print("Unexpected error")
- raise
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement