-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_analyzer.sh
More file actions
executable file
·81 lines (72 loc) · 2.21 KB
/
run_analyzer.sh
File metadata and controls
executable file
·81 lines (72 loc) · 2.21 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/bin/bash
# A simple wrapper for the disk_analyzer.py script
# Make the script executable if it's not already
if [ ! -x ./disk_analyzer.py ]; then
echo "Making disk_analyzer.py executable..."
chmod +x ./disk_analyzer.py
fi
# Default values
TARGET_DIR="$HOME"
OUTPUT_DIR="./output"
MIN_SIZE="2.0"
USE_SUDO=false
QUIET_MODE=false
# Help function
show_help() {
echo "Usage: ./run_analyzer.sh [options]"
echo ""
echo "Options:"
echo " -d, --dir DIR Target directory to analyze (default: $HOME)"
echo " -o, --output DIR Output directory (default: ./output)"
echo " -m, --min-size GB Minimum size in GB to process subdirectories (default: 2.0)"
echo " -s, --sudo Use sudo for du commands (access more directories)"
echo " -q, --quiet Suppress error messages from du command"
echo " -h, --help Show this help message"
echo ""
echo "Example:"
echo " ./run_analyzer.sh --dir /Users/username --output ./disk_report --min-size 1.5 --sudo"
exit 0
}
# Parse command line arguments
while [[ "$#" -gt 0 ]]; do
case $1 in
-d|--dir) TARGET_DIR="$2"; shift ;;
-o|--output) OUTPUT_DIR="$2"; shift ;;
-m|--min-size) MIN_SIZE="$2"; shift ;;
-s|--sudo) USE_SUDO=true ;;
-q|--quiet) QUIET_MODE=true ;;
-h|--help) show_help ;;
*) echo "Unknown parameter: $1"; show_help ;;
esac
shift
done
echo "Disk Analyzer"
echo "============="
echo "Target Directory: $TARGET_DIR"
echo "Output Directory: $OUTPUT_DIR"
echo "Min Size for Recursion: ${MIN_SIZE}GB"
if [ "$USE_SUDO" = true ]; then
echo "Using sudo: Yes (will prompt for password if needed)"
else
echo "Using sudo: No"
fi
if [ "$QUIET_MODE" = true ]; then
echo "Error display: Suppressed"
else
echo "Error display: Showing all errors"
fi
echo ""
echo "Press Enter to continue or Ctrl+C to cancel..."
read
# Prepare command
CMD="python3 ./disk_analyzer.py \"$TARGET_DIR\" --output \"$OUTPUT_DIR\" --min-size \"$MIN_SIZE\""
if [ "$USE_SUDO" = true ]; then
CMD="$CMD --sudo"
fi
if [ "$QUIET_MODE" = true ]; then
CMD="$CMD --quiet"
fi
# Run the Python script
eval $CMD
echo ""
echo "Analysis complete. Check $OUTPUT_DIR for results."