-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcapnames.sh
executable file
·37 lines (32 loc) · 1.07 KB
/
capnames.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
#!/usr/bin/env bash
# version 1.0.2
# This script will capitalize the first letter of every file and directory in the
# path given. You can list specific files within the script and use -m to exclude them.
STARTDIR=$1
EXCLUDE=$2
if [ "$STARTDIR" = "" ] || [ "$STARTDIR" = "?" ] || [[ "$STARTDIR" = *-h* ]]; then
ECHO ""
ECHO "Usage: capnames.sh <directorypath> to parse. <-m>"
ECHO "-m to exclude specific files listed in the script."
ECHO ""
exit
fi
#Here we set BASHs internal IFS variable so directories/filenames are not broken into new lines when a space is found.
IFS=$'\n'
cd "$STARTDIR" || exit
FILES="*"
for F in $FILES
do
PROCESS=""
VARCAP=$(echo "${F}" | awk '{for(i=1;i<=NF;i++)sub(/./,toupper(substr($i,1,1)),$i)}1')
#Here we can exclude names from the process.
if [ "$EXCLUDE" = "-m" ]; then
if [ "$F" = "folder.jpg" ] || [ "$F" = "fanart.jpg" ] || [ "$F" = "season-all.jpg" ] || [ "$F" = "tvshow.nfo" ] || [ "$F" = "thumbs.db" ]; then
VARCAP="$F"
PROCESS="NOT "
fi
fi
echo "$PROCESS""Processing $F file..."
mv "$F" "$VARCAP"
done
unset IFS