diff --git a/scripts/rename_tutorial_src_files.py b/scripts/rename_tutorial_src_files.py index 9ac620e86..55bf72310 100644 --- a/scripts/rename_tutorial_src_files.py +++ b/scripts/rename_tutorial_src_files.py @@ -1,16 +1,30 @@ #%% -from pathlib import Path +from pathlib import Path, PurePath from string import digits #%% directory = Path("./docs/tutorial/src") -output_directory = Path("./docs/tutorial/out") -output_directory.mkdir(exist_ok=True) -files = sorted([Path(f) for f in directory.iterdir()]) -for i, f in enumerate(files): - f: Path - index = str(i + 1).zfill(2) - new_name = output_directory / f"tutorial{index}.py" - print(new_name) - f.rename(new_name) +dirs = sorted([Path(f) for f in directory.iterdir()]) +d: PurePath +sufix = "__out__" +for d in dirs: + if d.name.endswith(sufix): + continue + output_dir_name = d.name + "__out__" + output_directory = directory / output_dir_name + output_directory.mkdir(exist_ok=True) + files = sorted([Path(f) for f in d.iterdir()]) + for i, f in enumerate(files): + index = str(i + 1).zfill(3) + new_name = output_directory / f"tutorial{index}.py" + print(new_name) + f.rename(new_name) + +for d in dirs: + current_dir = Path(str(d) + sufix) + print(current_dir) + current_dir.rename(d) + + +#%%