delete label.cache in folder valid and train using pathlib import path in python

main.py
from pathlib import Path

# Define the path to the parent folder
parent_folder = Path('path/to/parent/folder')

# Define the paths to the cache files in the valid and train folders
valid_cache = parent_folder / 'valid' / 'label.cache'
train_cache = parent_folder / 'train' / 'label.cache'

# Delete the cache files if they exist
if valid_cache.exists():
    valid_cache.unlink()
    print(f'{valid_cache} deleted successfully')

if train_cache.exists():
    train_cache.unlink()
    print(f'{train_cache} deleted successfully')
528 chars
18 lines

related categories

gistlibby LogSnag