filter filenames for validity
This commit is contained in:
parent
c9cfdaa845
commit
c17c19b1a6
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue