-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcleanup
More file actions
executable file
·33 lines (28 loc) · 920 Bytes
/
Copy pathcleanup
File metadata and controls
executable file
·33 lines (28 loc) · 920 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
25
26
27
28
29
30
31
32
33
#!/usr/bin/env bash
# script used to delete all nonessential files in the directory,
# i.e. image files and other garbage in certain projects im doing
PROMPT="What kind of file extensions would you like to remove \
(for example: .png)? Type done to exit: "
while true; do
read -p "$PROMPT" type
if [[ $type == "done" ]]; then
printf "%s\n" "Exiting..."
exit 0
fi
read -p "Type the path to the directory you want to delete from: " dir
printf "%s" "WARNING: THIS WILL DELETE ALL $type FILE TYPES FROM THE $dir DIRECTORY."
read -p "ARE YOU SURE YOU WANT TO CONTINUE? (Y/N): " cont
eval path="$dir/*$type"
let 'count=0'
if [[ $cont == Y ]] || [[ $cont == y ]]; then
for file in $path; do
printf $s "removing $file"
rm $file 2>/dev/null
((count++))
done
printf "%s\n" "$count file(s) successfully removed."
else
printf "%s\n" "Exiting..."
exit 0
fi
done