xlsx-dir-map/xlsx_dir_map/directory.py

14 lines
418 B
Python
Raw Permalink Normal View History

2022-01-24 01:50:27 +00:00
import os
from pathlib import Path
2022-01-26 04:28:17 +00:00
keepcharacters = (' ', '/', '.', '_')
2022-01-24 01:50:27 +00:00
2022-01-26 04:28:17 +00:00
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)
2022-01-24 01:50:27 +00:00
def create_directories(outdir, paths):
for path in paths:
fullpath = f"{outdir}/{path}" if outdir is not None else path
create_directory(fullpath)