一時ファイルを削除する
子ディレクトリの第 1 階層にあるnode_modulesと.venvを削除する。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 | import pathlib
import shutil
def main():
targets = [
*list(map(lambda x: x.as_posix(), pathlib.Path().glob("*/node_modules"))),
*list(map(lambda x: x.as_posix(), pathlib.Path().glob("*/.venv"))),
]
print("\n".join(targets))
result = input("Delete? (y/N): ")
if result != "y":
print("Cancelled")
return
for target in targets:
shutil.rmtree(target)
print(f"Deleted: {target}")
print("Deleted")
if __name__ == "__main__":
main()
|