-
Notifications
You must be signed in to change notification settings - Fork 0
/
remove_unused_figs.sh
48 lines (38 loc) · 1.16 KB
/
remove_unused_figs.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
41
42
43
44
45
46
47
#!/bin/bash
# Check if the directory argument is provided
if [ $# -eq 0 ]; then
echo "Usage: $0 <directory>"
exit 1
fi
# Assign the first argument to the directory variable
directory="$1"
# Check if the provided directory exists
if [ ! -d "$directory" ]; then
echo "Directory $directory does not exist."
exit 1
fi
# Change directory to the provided directory
cd "$directory" || exit
# Call make command
make
# Create directory to move images
mkdir -p "figures/unused_figs"
# Loop through each image file in the provided directory (excluding figures/unused_figs)
for image_file in "figures/"*
do
# Exclude figures/unused_figs directory
if [[ "$image_file" != "figures/unused_figs" ]]; then
# Extract filename without directory path
filename=$(basename "$image_file")
# Check if the file is mentioned more than once in any log file
if grep -q -c "$filename" ./*.log
then
echo "File $filename is in use."
else
echo "File $filename is not in use."
mv "$image_file" "figures/unused_figs/$filename"
fi
fi
done
# Clean up after processing the files
make clean