| import os |
| import json |
|
|
| BASE_URL = "https://SUA_URL_AQUI/" |
|
|
| def get_files(directory): |
| files_list = [] |
| |
| for root, dirs, files in os.walk(directory): |
| for file in files: |
| if file in ['gerar_files.py', 'client_config.json', 'files.json']: |
| continue |
| |
| filepath = os.path.join(root, file) |
| rel_path = os.path.relpath(filepath, directory) |
| rel_path = rel_path.replace("\\", "/") |
| |
| size = os.path.getsize(filepath) |
| |
| files_list.append({ |
| "name": file, |
| "size": size, |
| "path": rel_path, |
| "url": BASE_URL + rel_path |
| }) |
| return files_list |
|
|
| if __name__ == "__main__": |
| base_dir = "." |
| |
| data = {"files": get_files(base_dir)} |
| |
| with open("files.json", "w", encoding="utf-8") as f: |
| json.dump(data, f, indent=4, separators=(',', ': ')) |
| |
| print(f"Sucesso. {len(data['files'])} arquivos mapeados.") |
|
|