Skip to content

Instantly share code, notes, and snippets.

@Ljiong201108
Created February 10, 2026 00:56
Show Gist options
  • Select an option

  • Save Ljiong201108/e5a2fe8f8ac63f3cc70bf5557a948377 to your computer and use it in GitHub Desktop.

Select an option

Save Ljiong201108/e5a2fe8f8ac63f3cc70bf5557a948377 to your computer and use it in GitHub Desktop.
A sample python script to process the PBR texture packs for the Radiance mod
import shutil
import argparse
import zipfile
import os
from pathlib import Path
def move_files(root_dir, suffix, target_subfolder):
root = Path(root_dir)
count = 0
for file_path in root.rglob(f'*{suffix}'):
try:
parts = file_path.parts
if 'assets' not in parts or 'textures' not in parts:
continue
texture_dir = None
for parent in file_path.parents:
if parent.name == 'textures':
texture_dir = parent
break
if texture_dir is None:
continue
if target_subfolder in file_path.relative_to(texture_dir).parts:
continue
rel_path = file_path.relative_to(texture_dir)
dest_path = texture_dir / target_subfolder / rel_path
dest_path.parent.mkdir(parents=True, exist_ok=True)
shutil.move(str(file_path), str(dest_path))
count += 1
except Exception as e:
print(f" [Error] Processing {file_path.name}: {e}")
return count
def zip_folder(folder_path, output_path):
folder_path = Path(folder_path)
with zipfile.ZipFile(output_path, 'w', zipfile.ZIP_DEFLATED) as zipf:
for file in folder_path.rglob('*'):
if file.is_file():
zipf.write(file, arcname=file.relative_to(folder_path))
def main():
parser = argparse.ArgumentParser(description="Unzip, organize textures, re-zip, and clean up.")
parser.add_argument("zip_file", help="The path to the source .zip file")
args = parser.parse_args()
zip_path = Path(args.zip_file).resolve()
if not zip_path.exists() or zip_path.suffix.lower() != '.zip':
print(f"Error: File '{zip_path}' not found or is not a .zip file.")
return
temp_extract_dir = zip_path.parent / (zip_path.stem + "_temp_processing")
output_zip_path = zip_path.parent / (zip_path.stem + "_processed.zip")
try:
print(f"1. Extracting '{zip_path.name}' to temporary folder...")
if temp_extract_dir.exists():
shutil.rmtree(temp_extract_dir)
with zipfile.ZipFile(zip_path, 'r') as zip_ref:
zip_ref.extractall(temp_extract_dir)
print(f"2. Organizing textures inside temp folder...")
s_count = move_files(temp_extract_dir, "_s.png", "specular")
n_count = move_files(temp_extract_dir, "_n.png", "normal")
print(f" - Moved {s_count} specular maps.")
print(f" - Moved {n_count} normal maps.")
print(f"3. Re-packing into '{output_zip_path.name}'...")
zip_folder(temp_extract_dir, output_zip_path)
except Exception as e:
print(f"\n[CRITICAL ERROR]: {e}")
print("Cleanup may not have finished due to error.")
return
finally:
if temp_extract_dir.exists():
print(f"4. Cleaning up temporary files...")
shutil.rmtree(temp_extract_dir)
print("-" * 30)
print("Success! Process completed.")
print(f"New file location: {output_zip_path}")
if __name__ == "__main__":
main()
@sean81
Copy link

sean81 commented Feb 11, 2026

Hey, I was wondering, could you show me how I can use this script as I want to try the radiance mod with the texture pack

@semilt
Copy link

semilt commented Feb 11, 2026

@sean81

  1. Make sure you have python installed in your computer
  2. Create an empty folder and an empty .py file, maybe call it resource_pack_processer.py
  3. Copy all the code above into the .py file you created
  4. For simplicity, copy your resource pack zip file into the folder you created
  5. Launch powershell, navigate to the current directory
  6. Run python resource_pack_processer.py <your resource pack zip file name>.zip (if the name of the resource pack contains spaces, warp the name with ", e.g. "abc def.zip")
  7. The new zip file with name ended with processed is the file you need

@alakayy
Copy link

alakayy commented Feb 12, 2026

@sean81

  1. Make sure you have python installed in your computer
  2. Create an empty folder and an empty .py file, maybe call it resource_pack_processer.py
  3. Copy all the code above into the .py file you created
  4. For simplicity, copy your resource pack zip file into the folder you created
  5. Launch powershell, navigate to the current directory
  6. Run python resource_pack_processer.py <your resource pack zip file name>.zip (if the name of the resource pack contains spaces, warp the name with ", e.g. "abc def.zip")
  7. The new zip file with name ended with processed is the file you need

thx <3

@Pymla
Copy link

Pymla commented Feb 12, 2026

@sean81

  1. Make sure you have python installed in your computer
  2. Create an empty folder and an empty .py file, maybe call it resource_pack_processer.py
  3. Copy all the code above into the .py file you created
  4. For simplicity, copy your resource pack zip file into the folder you created
  5. Launch powershell, navigate to the current directory
  6. Run python resource_pack_processer.py <your resource pack zip file name>.zip (if the name of the resource pack contains spaces, warp the name with ", e.g. "abc def.zip")
  7. The new zip file with name ended with processed is the file you need

thank u for making life easier

@aircoolbro21
Copy link

aircoolbro21 commented Mar 2, 2026

hey yall i need some help, every time i do it, it spits out

  File "C:\Users\User\Desktop\Rp_processor\resource_pack_processer.py", line 56
    ...         print(f"Error: File '{zip_path}' not found or is not a .zip file.")
IndentationError: expected an indented block after 'if' statement on line 55

am i missing something? my command is python resource_pack_processer.py Vanilla-labPBR-1-3-2.zip no matter what resource pack i use it doesnt seem to work, tried administrator and recopying the script maybe a dozen times now lol, it just keeps spitting out not found. thanks in advance!
quick edit: ive also tried the full file path to .zip with and without double quotation

@Xeo872
Copy link

Xeo872 commented Mar 3, 2026

hey yall i need some help, every time i do it, it spits out

  File "C:\Users\User\Desktop\Rp_processor\resource_pack_processer.py", line 56
    ...         print(f"Error: File '{zip_path}' not found or is not a .zip file.")
IndentationError: expected an indented block after 'if' statement on line 55

am i missing something? my command is python resource_pack_processer.py Vanilla-labPBR-1-3-2.zip no matter what resource pack i use it doesnt seem to work, tried administrator and recopying the script maybe a dozen times now lol, it just keeps spitting out not found. thanks in advance! quick edit: ive also tried the full file path to .zip with and without double quotation

don't copy code
download script directy
right click on raw then Save link as
it will download script and wont give error

@plakek1
Copy link

plakek1 commented Mar 3, 2026

could you please post an example of how the command should look in PowerShell?

@aircoolbro21
Copy link

don't copy code
download script directy
right click on raw then Save link as
it will download script and wont give error

Thank you! this worked.

@plakek1
Copy link

plakek1 commented Mar 3, 2026

don't copy code
download script directy
right click on raw then Save link as
it will download script and wont give error

Thank you! this worked.

what did you type in powershell? i've been trying for an hour straight

@Xeo872
Copy link

Xeo872 commented Mar 3, 2026

don't copy code
download script directy
right click on raw then Save link as
it will download script and wont give error

Thank you! this worked.

what did you type in powershell? i've been trying for an hour straight

Make sure you have installed python
And PS is in same folder where process_pbr_pack.py and .zip is
For Vanilla-labPBR-1-3-2.zip
Cmd should look like this
python process_pbr_pack.py "Vanilla-labPBR-1-3-2.zip"

@plakek1
Copy link

plakek1 commented Mar 3, 2026

don't copy code
download script directy
right click on raw then Save link as
it will download script and wont give error

Thank you! this worked.

what did you type in powershell? i've been trying for an hour straight

Make sure you have installed python And PS is in same folder where process_pbr_pack.py and .zip is For Vanilla-labPBR-1-3-2.zip Cmd should look like this python process_pbr_pack.py "Vanilla-labPBR-1-3-2.zip"

it worked, i thought i had python installed but apparently not, thanks

@georgefisherlamb
Copy link

@georgefisherlamb
Copy link

hey yall i need some help, every time i do it, it spits out

  File "C:\Users\User\Desktop\Rp_processor\resource_pack_processer.py", line 56
    ...         print(f"Error: File '{zip_path}' not found or is not a .zip file.")
IndentationError: expected an indented block after 'if' statement on line 55

am i missing something? my command is python resource_pack_processer.py Vanilla-labPBR-1-3-2.zip no matter what resource pack i use it doesnt seem to work, tried administrator and recopying the script maybe a dozen times now lol, it just keeps spitting out not found. thanks in advance! quick edit: ive also tried the full file path to .zip with and without double quotation

don't copy code download script directy right click on raw then Save link as it will download script and wont give error

https://chatgpt.com/share/69a71d31-47fc-800b-977c-eba5ef8fee95

@XxsjrapsxX
Copy link

hey does anyone else have a weird issue where none of the resourcepacks you drop in the folder show up in the actual menu in minecraft itself?

@Octably
Copy link

Octably commented Mar 3, 2026

hey does anyone else have a weird issue where none of the resourcepacks you drop in the folder show up in the actual menu in minecraft itself?

Yes but I'm unsure how to fix it yet.

@dacryphiliac
Copy link

Step by step guide for noobs:

  1. Download Python
  2. Download the Python file by clicking Raw > Right click > Save as > Save
  3. Create an Empty Folder. Put the Resource Pack .zip file you want to re-process in the folder as well as process_pbr_pack.py.
  4. Right click an empty spot in the folder and Open Terminal. This will open Powershell.
  5. In Powershell type: python process_pbr_pack.py "SPBR-18_7[Legacy].zip" <--- replace what's inside "" with whatever your Resoure Pack's file name is, including .zip.
  6. Drag and Drop the new Processed Zip file into your resource packs folder.

@SheanlR
Copy link

SheanlR commented Mar 4, 2026

Step by step guide for noobs:
5. In Powershell type: python process_pbr_pack.py "SPBR-18_7[Legacy].zip" <--- replace what's inside "" with whatever your Resoure
Pack's file name is, including .zip.

In step 5, you can also type python and then use the Tab key to select files in the folder in the correct order.

@CompletedLoop
Copy link

hey does anyone else have a weird issue where none of the resourcepacks you drop in the folder show up in the actual menu in minecraft itself?

same issue here with spbr and pixili seems to put the game stuck in the mojang loading screen

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