-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathRemoveFiles.py
More file actions
executable file
·24 lines (18 loc) · 898 Bytes
/
Copy pathRemoveFiles.py
File metadata and controls
executable file
·24 lines (18 loc) · 898 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/env python3
# created by Alexander Deca - Deca Consulting 06/07/2023
# please note there is a requirements file -> pip install -r requirements.txt
# this script iterates over a directory and deletes files with _diff.txt
import os
directory_path = 'output'
# Recursive function to iterate over files and subdirectories
def delete_files_with_diff_txt(directory):
for root, dirs, files in os.walk(directory):
for filename in files:
file_path = os.path.join(root, filename)
# Check if the file is a regular file and if it contains "_diff.txt" in its name
if "_diff.txt" in filename:
# Delete the file
os.remove(file_path)
print(f"Deleted file: {file_path}")
# Call the function to delete files in the directory and its subdirectories
delete_files_with_diff_txt(directory_path)