File size: 1,026 Bytes
7de1795
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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.")