from pathlib import Path path = Path('/raw') with open('regina.txt') as fd: for subdir in fd: subdir = subdir.strip() (path / subdir).mkdir(parents=True, exist_ok=True)This creates the Paths /raw/{line_in_regina.txt} ...
This creates also the parent path raw. If a directory already exists (exist_ok=True), then it's continuing without any error.
The os.path is old style, pathlib has many convenient methods.
If the names of the folders should be in ('raw', 'right', 'left'), then the code is a bit different.
from pathlib import Path pasths = ('raw', 'right', 'left') with open('regina.txt') as fd: for path in paths: for subdir in fd: subdir = subdir.strip() Path(path, subdir).mkdir(parents=True, exist_ok=True)This will create the directories ('raw', 'right', 'left') and will create in each directory the subdirectories from
regina.txt
.Is that what you want?
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
All humans together. We don't need politicians!