2021-12-09 03:41:19 +00:00
|
|
|
# Purpose:
|
2021-12-09 16:57:05 +00:00
|
|
|
# This file goes through all batches, renames, and sorts all nft files to a Complete_Collection folder in Blend_My_NFTs
|
|
|
|
|
2021-12-09 03:41:19 +00:00
|
|
|
import bpy
|
|
|
|
import os
|
|
|
|
import json
|
2022-02-03 23:48:52 +00:00
|
|
|
import shutil
|
2021-12-09 03:41:19 +00:00
|
|
|
|
2022-08-24 14:50:51 +00:00
|
|
|
from .Helpers import TextColors, removeList, remove_file_by_extension
|
2022-01-09 01:33:25 +00:00
|
|
|
|
2022-01-28 22:20:58 +00:00
|
|
|
|
2022-03-11 01:03:20 +00:00
|
|
|
def reformatNFTCollection(refactor_panel_input):
|
|
|
|
completeCollPath = os.path.join(refactor_panel_input.save_path, "Blend_My_NFTs Output", "Complete_Collection")
|
2022-05-31 05:28:01 +00:00
|
|
|
|
2021-12-09 16:28:28 +00:00
|
|
|
if not os.path.exists(completeCollPath):
|
|
|
|
os.mkdir(completeCollPath)
|
2021-12-09 12:52:32 +00:00
|
|
|
|
2022-03-11 01:03:20 +00:00
|
|
|
batchListDirty = os.listdir(refactor_panel_input.nftBatch_save_path)
|
2022-05-31 05:28:01 +00:00
|
|
|
batchList = remove_file_by_extension(batchListDirty)
|
2022-04-20 01:54:17 +00:00
|
|
|
collection_info = {"Total Time": 0}
|
2022-05-10 12:14:53 +00:00
|
|
|
|
2022-05-31 05:28:01 +00:00
|
|
|
for folder in batchList:
|
|
|
|
batch_info = json.load(open(os.path.join(refactor_panel_input.nftBatch_save_path, folder, "batch_info.json")))
|
|
|
|
collection_info[os.path.basename(folder)] = batch_info
|
|
|
|
collection_info["Total Time"] = collection_info["Total Time"] + batch_info["Batch Render Time"]
|
|
|
|
|
|
|
|
fileListDirty = os.listdir(os.path.join(refactor_panel_input.nftBatch_save_path, folder))
|
|
|
|
filelist = remove_file_by_extension(fileListDirty)
|
2022-05-10 12:14:53 +00:00
|
|
|
|
2022-05-31 05:28:01 +00:00
|
|
|
for mediaTypeFolder in filelist:
|
|
|
|
if mediaTypeFolder != "batch_info.json":
|
|
|
|
mediaTypeFolderDir = os.path.join(refactor_panel_input.nftBatch_save_path, folder, mediaTypeFolder)
|
2022-05-10 12:14:53 +00:00
|
|
|
|
2022-05-31 05:28:01 +00:00
|
|
|
for i in os.listdir(mediaTypeFolderDir):
|
|
|
|
destination = os.path.join(completeCollPath, mediaTypeFolder)
|
|
|
|
if not os.path.exists(destination):
|
|
|
|
os.makedirs(destination)
|
2022-04-20 01:54:17 +00:00
|
|
|
|
2022-05-31 05:28:01 +00:00
|
|
|
shutil.move(os.path.join(mediaTypeFolderDir, i), destination)
|
2022-04-20 01:54:17 +00:00
|
|
|
|
|
|
|
collection_info = json.dumps(collection_info, indent=1, ensure_ascii=True)
|
|
|
|
with open(os.path.join(completeCollPath, "collection_info.json"), 'w') as outfile:
|
|
|
|
outfile.write(collection_info + '\n')
|
|
|
|
|
2022-03-11 01:03:20 +00:00
|
|
|
print(f"All NFT files stored and sorted to the Complete_Collection folder in {refactor_panel_input.save_path}")
|
|
|
|
|
|
|
|
shutil.rmtree(refactor_panel_input.nftBatch_save_path)
|
2022-05-31 05:28:01 +00:00
|
|
|
|