filter filenames for validity

This commit is contained in:
alex 2022-01-25 23:28:17 -05:00
parent c9cfdaa845
commit c17c19b1a6
2 changed files with 5 additions and 4 deletions

View File

@ -11,10 +11,8 @@ args = parser.parse_args()
from spreadsheet import get_names_list
names = get_names_list(args.file_in, args.cell_range, args.column_groups)
print(names)
from directory import create_directories
create_directories(args.out, names)
#print(args.column_groups)

View File

@ -1,9 +1,12 @@
import os
from pathlib import Path
def create_directory(name):
Path(name).mkdir(parents=True, exist_ok=True)
keepcharacters = (' ', '/', '.', '_')
def create_directory(name):
filename = "".join([c for c in name if c.isalnum() or c in keepcharacters]).rstrip()
Path(filename).mkdir(parents=True, exist_ok=True)
def create_directories(outdir, paths):
for path in paths:
fullpath = f"{outdir}/{path}" if outdir is not None else path