python3 main.py "root_dir" "sub_dir/*"
python3 main.py "~/" "Documents/*"
from pathlib import Path | |
import os | |
import json | |
import sys | |
paths = [] | |
for txt_path in Path(sys.argv[1]).glob(sys.argv[2]): | |
paths.append(os.path.basename(txt_path)) | |
with open("data.json", "w") as write_file: | |
json.dump({"files": paths}, write_file) |