-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRemoveFoldersFiles.sh
More file actions
37 lines (31 loc) · 1.04 KB
/
Copy pathRemoveFoldersFiles.sh
File metadata and controls
37 lines (31 loc) · 1.04 KB
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
# Remove Folder
# Version 06.11.2023
# Created by: Dean Hoile
#Easy script to remove folders and or files in bulk, remember that certain directories will require the script to be run with sudo/root.
#!/bin/zsh
# Set the folder paths and executable file you want to search for
folders_and_files_to_remove=(
"/Library/Application Support/Dialog"
"/usr/local/bin/dialog"
)
# Set the log file path
log_file="/Library/Logs/text.log"
# Function to remove folders and files
remove_item() {
local item="$1"
echo "Removing: $item"
rm -rf "$item" >> "$log_file" 2>&1
}
# Iterate over folders and files and remove them if they exist
for item in "${folders_and_files_to_remove[@]}"; do
if [ -e "$item" ]; then
remove_item "$item"
if [ $? -eq 0 ]; then
echo "Successfully removed: $item" | tee -a "$log_file"
else
echo "Error: Unable to remove: $item. Check the log file for details." | tee -a "$log_file"
fi
else
echo "Item not found: $item" | tee -a "$log_file"
fi
done