-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDelete_NonMP4s.sh
More file actions
43 lines (35 loc) · 1015 Bytes
/
Copy pathDelete_NonMP4s.sh
File metadata and controls
43 lines (35 loc) · 1015 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
34
35
36
37
38
39
40
41
42
43
#!/bin/bash
#author : Hampton Ford
#purpose : Removes everything but MP4s and PNGs. Made to streamline Chris' autogenerated Go-Pro footage cleanup.
if [ $# -eq 0 ]; then
printf "USAGE:\n"
printf "Run with ./GoProDel_NonMP3s.sh [drop_and_drop GoPro folder].\n\n\n"
fi
if [ $# -ne 1 ]; then
printf "ERROR:\n"
printf "You forgot to drag and drop the folder.\n"
exit 0
fi
directory=$1
# prompt to backup
read -p "Would you like to make a backup folder? " CHOICE;
CHOICE=${CHOICE^^}
if [[ "${CHOICE}" == "Y" || "${CHOICE}" == "YES" ]]; then
cd ${directory}
cd ..
cp -fr ${directory} ${directory}.backup
fi
cd ${directory}
files=$(ls $1)
for file in ${files}; do
# Parse out name w/out extension
f1=$(echo ${file} | cut -d '.' -f 1 | awk '{$1=$1};1')
f2=$(echo ${file} | cut -d '.' -f 2 | awk '{$1=$1};1')
f1=${f1^^}
f2=${f2^^}
# Delete all not mp4s or png
if [[ "${f2}" != "MP4" && "${f2}" != "PNG" ]]; then
rm -f "${directory}/${file}" 2>&1
fi
done
printf "Task completed successfully.\n"