File size: 1,369 Bytes
e06edfe
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import os

def log_zip_files(root_folder, output_file):
    with open(output_file, "w") as f:
        for dirpath, dirnames, filenames in os.walk(root_folder):
            for file in filenames:
                if file.lower().endswith(".zip"):
                    # Write only the file name (not the full path)
                    f.write(file + "\n")

if __name__ == "__main__":
    # Set the directory you want to start searching from; here it's the current directory
    root_folder = "."
    output_file = "zip_files.txt"
    log_zip_files(root_folder, output_file)
    print(f"ZIP file names logged in '{output_file}'.")
import os

def log_zip_files(root_folder, output_file):
    with open(output_file, "w") as f:
        for dirpath, dirnames, filenames in os.walk(root_folder):
            for file in filenames:
                if file.lower().endswith(".zip"):
                    # Remove the .zip extension and write only the file name
                    file_name_without_ext, _ = os.path.splitext(file)
                    f.write(file_name_without_ext + "\n")

if __name__ == "__main__":
    # Set the directory you want to start searching from; here it's the current directory
    root_folder = "."
    output_file = "zip_files.txt"
    log_zip_files(root_folder, output_file)
    print(f"ZIP file names without extension logged in '{output_file}'.")