skip uncompressed blends

This commit is contained in:
Nathan
2025-09-17 13:54:16 -06:00
parent 7693de5c48
commit 0859f8baba
2 changed files with 351 additions and 0 deletions

View File

@@ -45,6 +45,18 @@ echo blend_files = sys.argv[sys.argv.index^("--"^) + 1:] if "--" in sys.argv els
echo.
echo print^("Found " + str^(len^(blend_files^)^) + " .blend files to compress"^)
echo.
echo def is_compressed_file^(path^):
echo try:
echo with open^(path, 'rb'^) as f:
echo header = f.read^(4^)
echo if header[:2] == b'\x1f\x8b': # gzip
echo return True
echo if header == b'\x28\xb5\x2f\xfd': # zstd
echo return True
echo return False
echo except Exception:
echo return False
echo.
echo for blend_file in blend_files:
echo if blend_file.lower^(^).endswith^(".blend"^):
echo try:
@@ -55,6 +67,10 @@ echo # Check if output file already exists
echo if os.path.exists^(output_file^):
echo print^("SKIP_EXISTING:" + blend_file^)
echo continue
echo # Skip if source is already compressed
echo if is_compressed_file^(blend_file^):
echo print^("SKIP_ALREADY_COMPRESSED:" + blend_file^)
echo continue
echo print^("PROCESSING:" + blend_file^)
echo # Load the blend file
echo bpy.ops.wm.open_mainfile^(filepath=blend_file^)
@@ -133,6 +149,10 @@ for /f "tokens=1,2,3 delims=:" %%a in (blender_output.txt) do (
set /a skipped+=1
echo [!skipped!] SKIPPED ^(not .blend^): %%b
echo.
) else if "%%a"=="SKIP_ALREADY_COMPRESSED" (
set /a skipped+=1
echo [!skipped!] SKIPPED ^(already compressed^): %%b
echo.
)
)