-
Notifications
You must be signed in to change notification settings - Fork 0
/
audio_ripper.sh
executable file
·66 lines (55 loc) · 1.42 KB
/
audio_ripper.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
56
57
58
59
60
61
62
63
64
65
66
#!/bin/bash
#
# Author: Nate Levesque <[email protected])
# Language: Shell
# Filename: audio_ripper.sh
#
# Description:
# rips audio from a directory of video/audio files to .aac format
#
#
# Implement common code for dependency checks
depCheck(){
# Checks if a piece of software exists on a system and
# if it doesn't, stops execution and exits with an error.
#
# Arguments:
# $1: a command to test
#
if [ ! `command -v $1` ]; then
echo "You need $1 installed to use this script, exiting..."
exit 1
fi
}
# Check that required software is available
depCheck ffmpeg
read -p "Name prefix for group of files or filename to rip: " prefix
echo "Ripping from files in `pwd`"
#
# Creates a directory to store the ripped audio
mkdir ripped-audio 2>/dev/null
#
# Checks to see if ls returns any files with the given prefix, if not
# informs the user and exits.
if [ "`ls | grep $prefix`" == "" ]; then
echo "No files to rip."
exit 0
else
# Iterates through the directory and rips all the files that match
# the given prefix
for file in $prefix* ; do
ffmpeg -i $file -acodec copy ripped-audio/$file.aac
done
fi
# Asks the user whether or not to keep the source files
read -p "Keep source files? y/n: " keep
case $keep in
"n"|"N")
rm $prefix*
echo "Removed source files."
;;
"y"|"Y")
echo "Kept source files"
;;
esac
exit 0