S SmartDocs
Serie: AI for Chemistry python 20 líneas · Actualizado 2024-06-25

cosmo.py

AI for Chemistry/2025_COSMO/data/s-profiles-all/check/cosmo.py

import os

# path
folder_path = r"D:\COSMOSAC-master\COSMO\COSMO_all\s-profiles-all\check\List-9"

# just keep the .cosmo file
file_extensions = [".gjf", ".log", ".chk"]

# all files
for root, dirs, files in os.walk(folder_path):
    for file in files:
        file_path = os.path.join(root, file)
        # check
        if any(file.endswith(ext) for ext in file_extensions):
            try:
                # remove
                os.remove(file_path)
                print(f"Deleted: {file_path}")
            except Exception as e:
                print(f"Error deleting {file_path}: {e}")

Artículos relacionados