Last active
September 15, 2020 21:07
-
-
Save dreisicht/70e0f248df2a6b717265333012bdad00 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv | |
import os | |
from shutil import copy2 | |
def create_folders_from_csv(csv_file_path, output_dir): | |
with open(csv_file_path, newline='', encoding='utf-8') as csvfile: | |
data = csv.reader(csvfile, dialect='excel') | |
for row in data: | |
dirpath = os.path.join(output_dir, row[0].replace('?', '').replace(':', '')) | |
try: | |
os.makedirs(dirpath) | |
print(f'Created folder {dirpath}') | |
except FileExistsError: | |
pass | |
def create_blend_files_from_csv(csv_file_path, base_blend_path, output_dir, suffix): | |
with open(csv_file_path, newline='', encoding='utf-8') as csvfile: | |
data = csv.reader(csvfile, dialect='excel') | |
for row in data: | |
target_dir = row[0].replace('?', '').replace(':', '') | |
target_file = os.path.join(os.path.join(output_dir, target_dir), f'{target_dir}_{suffix}.blend') | |
copy2(base_blend_path, target_file) | |
print(f'Copied {target_file}') | |
######################### DEFINITIONS ################################## | |
CSVFILE = 'Stella Shot List Spreadsheet - Tabellenblatt1.csv' | |
BASE_BLEND = 'C:\\Users\\peter\\Desktop\\base.blend' | |
OUTPUT_DIR = 'C:\\Users\\peter\\Desktop\\opt' | |
######################################################################## | |
create_folders_from_csv(CSVFILE, OUTPUT_DIR) | |
create_blend_files_from_csv(CSVFILE, BASE_BLEND, OUTPUT_DIR, 'my_other_suffix') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment