-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclear_volume.sh
executable file
·55 lines (42 loc) · 1.67 KB
/
clear_volume.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
48
49
50
51
52
53
54
55
#!/bin/bash
# for safety: https://sipb.mit.edu/doc/safe-shell/
set -uf -o pipefail
while true; do
echo
echo "================================================================================"
echo
read -p "Enter the disk letter to clear: " -n 1 -r
echo
DISK_LETTER=$(echo "$REPLY" | tr '[:lower:]' '[:upper:]')
VOLUME_PATH="/Volumes/Video ${DISK_LETTER}"
read -p "This will permanently delete all files on \"${VOLUME_PATH}\". Proceed? [yN] " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo "OK, doing nothing."
continue
fi
diskutil reformat "$VOLUME_PATH"
EXIT_CODE=$?
if [[ $EXIT_CODE != 0 ]]; then
echo "================================================================================"
echo "================================================================================"
echo "====== ======"
echo "====== WARNING: Disk not cleared ======"
echo "====== ======"
echo "================================================================================"
echo "================================================================================"
continue
fi
touch "${VOLUME_PATH}/FILE NAMING CONVENTION"
touch "${VOLUME_PATH}/No need to rename backup recording files"
touch "${VOLUME_PATH}/YYYY-MM-DD HHHH N"
echo
echo "Finished. Current space on Video ${DISK_LETTER}:"
df -h "$VOLUME_PATH"
diskutil unmount "$VOLUME_PATH"
EXIT_CODE=$?
if [[ $EXIT_CODE != 0 ]]; then
echo "====== WARNING: Disk not ejected ======"
continue
fi
done