-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcleanup.sh
executable file
·41 lines (35 loc) · 1.22 KB
/
cleanup.sh
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
38
39
40
#!/bin/bash
# Check if the directory name is provided
if [ -z "$1" ]; then
echo "Please provide a directory name."
exit 1
fi
# Directory provided as an argument
TARGET_DIR="$1"
# Find and remove all .gitignore files in the specified directory
find "$TARGET_DIR" -maxdepth 1 -type f -name ".gitignore" -exec rm -v {} \;
find "$TARGET_DIR" -maxdepth 1 -type f -name "README.md" -exec rm -v {} \;
# Find all src folders and remove specified files within them
find "$TARGET_DIR" -maxdepth 1 -type d -name "src" | while read -r src_dir; do
FILES_TO_REMOVE=( "App.test.js" "logo.svg" "reportWebVitals.js" "setupTests.js" )
for file in "${FILES_TO_REMOVE[@]}"; do
file_path="$src_dir/$file"
if [ -f "$file_path" ]; then
rm -v "$file_path"
else
echo "$file_path not found"
fi
done
done
# Find all public folders and remove specified files within them
find "$TARGET_DIR" -maxdepth 1 -type d -name "public" | while read -r public_dir; do
FILES_TO_REMOVE=("favicon.ico" "logo192.png" "logo512.png" "robots.txt")
for file in "${FILES_TO_REMOVE[@]}"; do
file_path="$public_dir/$file"
if [ -f "$file_path" ]; then
rm -v "$file_path"
else
echo "$file_path not found"
fi
done
done