-
Notifications
You must be signed in to change notification settings - Fork 0
/
soxbatch
executable file
·43 lines (36 loc) · 976 Bytes
/
soxbatch
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/sh
if [ -z "$1" ] ; then
echo "ERROR: No file search provided"
exit 1
fi
if [ -z "$2" ] ; then
echo "ERROR: No output format specified"
exit 1
fi
if [ -z "$3" ] ; then
echo "WARNING: No sox options provided"
fi
echo "" # give me some space
# originally used a FILES variable
# FILES="$(pwd)/$1"
# for f in *$1 #$FILES
COUNT=1; # start a counter
find . -iname "$1" | while read f
do
echo "File# $COUNT";
FILENAME=$(basename "$f"); #echo "filename is: $FILENAME";
BASENAME=${FILENAME%.*}; #echo "basename is: $BASENAME";
EXT="${FILENAME##*.}"
CONVERTCODE="sox \"$BASENAME.$EXT\" $3 \"$BASENAME.$2\" -S -V2"
echo "Convert code:" $CONVERTCODE # just print out the code that will run
echo "";
if [ "$4" ] ; then
echo $CONVERTCODE | /bin/bash # actually run the code if switch is present
fi
COUNT=$((COUNT+1)); # increment counter
done
echo ""
if [ -z "$4" ] ; then
echo "SCRIPT WAS NOT RUN! Add '1' at the end of the command to activate"
fi
echo ""