#!/bin/bash
END=$(cdparanoia -Q 2>&1| awk ' $1+0 > 0 { # when the first field converted to a number is greater than 0
n = $1+0; # save the first field as a number in variable n
next; # continue processing with next line of input (not required for this case, but good form)
}
END { # execute this code after the last line of input has been processed
print n}') # print the value of n to standard output
cdparanoia 1-$END $1.wav
lame --abr 16 -mm -a "$1.wav" "$1.mp3"
rm $1.wav
eject cdrom
sox "$1.mp3" -t mp3 1.4/"$1.mp3" tempo 1.4 &
This rips to a .wav specified by $1, converts it to an mp3, deletes the .wav then advances the tempo of the .mp3 by 1.4x and saves both .mp3s.
So what I was hoping to do was to automate things a bit and call this as a subroutine in a script that would auto rename the files as I ripped each disc. I think I got it working with this:
Code:
#!/bin/bash
FILE=$1
num=1
while [ $num -lt 10 ]
do
if [ -f $FILE"0"$num.mp3 ];
then
echo "File $FILE"0"$num exists"
else
echo "File $FILE"0"$num does not exist"
./rip $FILE"0"$num
exit
fi
num=$[$num +1]
done
while [ $num -ge 10 ]
do
#echo "second loop $num"
if [ -f $FILE$num.mp3 ];
then
echo "File $FILE$num exists"
else
echo "File $FILE$num does not exist"
./rip $FILE$num
exit
fi
num=$[$num +1]
done
echo "done"
unfortunately, if I want to use my standard format for file names which is "Title -- Disc ##.mp3", I can't get it to work with
Code:
#!/bin/bash
FILE=$1
num=1
while [ $num -lt 10 ]
do
if [ -f $FILE' -- Disc 0'$num.mp3 ];
then
echo "File $FILE" -- Disc 0"$num exists"
else
echo "File $FILE" -- Disc 0"$num does not exist"
./rip $1' -- Disc 0'$num
fi
num=$[$num +1]
done
while [ $num -ge 10 ]
do
#echo "second loop $num"
if [ -f $FILE$num.mp3 ];
then
echo "File $FILE$num exists"
else
echo "File $FILE$num does not exist"
./rip $FILE$num
exit
fi
num=$[$num +1]
done
echo "done"
Forgetting of course that I haven't updated the second while loop for an input such as Freddy and Fredericka as my $1.
a) what can I clean up from my first attempt at sequentially numbering file names and
b) how can I get it to use the $1 of something like Freddy and Fredricka ?
c) how do I put my ./rip script in as a subroutine and call it? just name it and put it in {}s?
Hello,
I'm still learning unix and I have what is probably a simple question but I can't seem to find the question to. I have an Ultra 10 Sparc Server running solaris 8 and the drive may have crashed (I hope not). Currently, it appears some files in the /etc folder are missing. I have a backup... (1 Reply)
Hi
i am new to UNIX completely. i dont know any thing about UNIX.
can some one please help me with some books on the unix archetecture and all the internal working of UNIX OS (i want to know every thing about unix from basics) and shell programming.
can any one please if available provide... (1 Reply)
I am having following folder structure.
/root/audios/pop
/root/audios/jazz
/root/audios/rock
Inside those pop, jazz, rock folders there are following files,
p1.ul, p2.ul, p3.ul, j1.ul, j2.ul, j3.ul, r1.ul, r2.ul, r3.ul
And I have a file named as "audio.txt" in the path /root/audios,... (11 Replies)
Good evening, I'm currently working on a BASH script to convert audio between file formats and I've come across a snag. At the beginning of the script, I'm having the system check to see if any files with the .m4a extension exist in the directory, and if so, it runs the script. If there are no... (1 Reply)
I'm trying to record audio using Audacity 2.0.5 installed from SlackBuilds. My system is 64-bit Slackware 14.1 and a sound card is Intel HD Audio. I didn't change my sound system to OSS. (Default sound system in Slackware 14.1 is ALSA, isn't it?) First, I set Internal Microphone slider in KMix... (2 Replies)
This site is the first to get this snippet.
It will capture an audio recording of any time length within the limits of OSX's QuickTime Player's capablility...
A shell script derivative of this will be used as a further capture for CygWin's AudioScope.sh.
Thoroughly read ALL the comments in... (0 Replies)
I have a lot number audio files in the MP3 proprietary format, I want to convert them to 'opus' the free and higher quality format, with keep metadata also.
My selection command-line programs are SoX (Sound eXchange) for convert MP3 files to 'AIFF' format in order to keep quality and metadata*... (1 Reply)
This is a DEMO shell script to generate a simple graticule and plot inside it...
Apologies for any typos...
it is another building block along with my other two shell uploads recently to start a semi_serious project of an Terminal_AudioScope...
The fist upload I posted recently was to show... (83 Replies)
Just finished this Audible audio book. It's simply great.
Highly recommended:
This book was so well done that I did not want to miss a single word; so ended up listening to half of the book twice when I got distracted. This is a great audio book.
... (0 Replies)
Discussion started by: Neo
0 Replies
LEARN ABOUT SUNOS
num
Num(3o) OCaml library Num(3o)NAME
Num - Operation on arbitrary-precision numbers.
Module
Module Num
Documentation
Module Num
: sig end
Operation on arbitrary-precision numbers.
Numbers (type num ) are arbitrary-precision rational numbers, plus the special elements 1/0 (infinity) and 0/0 (undefined).
type num =
| Int of int
| Big_int of Big_int.big_int
| Ratio of Ratio.ratio
The type of numbers.
=== Arithmetic operations ===
val (+/) : num -> num -> num
Same as Num.add_num .
val add_num : num -> num -> num
Addition
val minus_num : num -> num
Unary negation.
val (-/) : num -> num -> num
Same as Num.sub_num .
val sub_num : num -> num -> num
Subtraction
val ( */ ) : num -> num -> num
Same as Num.mult_num .
val mult_num : num -> num -> num
Multiplication
val square_num : num -> num
Squaring
val (//) : num -> num -> num
Same as Num.div_num .
val div_num : num -> num -> num
Division
val quo_num : num -> num -> num
Euclidean division: quotient.
val mod_num : num -> num -> num
Euclidean division: remainder.
val ( **/ ) : num -> num -> num
Same as Num.power_num .
val power_num : num -> num -> num
Exponentiation
val abs_num : num -> num
Absolute value.
val succ_num : num -> num
succ n is n+1
val pred_num : num -> num
pred n is n-1
val incr_num : num Pervasives.ref -> unit
incr r is r:=!r+1 , where r is a reference to a number.
val decr_num : num Pervasives.ref -> unit
decr r is r:=!r-1 , where r is a reference to a number.
val is_integer_num : num -> bool
Test if a number is an integer
=== The four following functions approximate a number by an integer : ===
val integer_num : num -> num
integer_num n returns the integer closest to n . In case of ties, rounds towards zero.
val floor_num : num -> num
floor_num n returns the largest integer smaller or equal to n .
val round_num : num -> num
round_num n returns the integer closest to n . In case of ties, rounds off zero.
val ceiling_num : num -> num
ceiling_num n returns the smallest integer bigger or equal to n .
val sign_num : num -> int
Return -1 , 0 or 1 according to the sign of the argument.
=== Comparisons between numbers ===
val (=/) : num -> num -> bool
val (</) : num -> num -> bool
val (>/) : num -> num -> bool
val (<=/) : num -> num -> bool
val (>=/) : num -> num -> bool
val (<>/) : num -> num -> bool
val eq_num : num -> num -> bool
val lt_num : num -> num -> bool
val le_num : num -> num -> bool
val gt_num : num -> num -> bool
val ge_num : num -> num -> bool
val compare_num : num -> num -> int
Return -1 , 0 or 1 if the first argument is less than, equal to, or greater than the second argument.
val max_num : num -> num -> num
Return the greater of the two arguments.
val min_num : num -> num -> num
Return the smaller of the two arguments.
=== Coercions with strings ===
val string_of_num : num -> string
Convert a number to a string, using fractional notation.
val approx_num_fix : int -> num -> string
See Num.approx_num_exp .
val approx_num_exp : int -> num -> string
Approximate a number by a decimal. The first argument is the required precision. The second argument is the number to approximate.
Num.approx_num_fix uses decimal notation; the first argument is the number of digits after the decimal point. approx_num_exp uses scien-
tific (exponential) notation; the first argument is the number of digits in the mantissa.
val num_of_string : string -> num
Convert a string to a number.
=== Coercions between numerical types ===
val int_of_num : num -> int
val num_of_int : int -> num
val nat_of_num : num -> Nat.nat
val num_of_nat : Nat.nat -> num
val num_of_big_int : Big_int.big_int -> num
val big_int_of_num : num -> Big_int.big_int
val ratio_of_num : num -> Ratio.ratio
val num_of_ratio : Ratio.ratio -> num
val float_of_num : num -> float
OCamldoc 2012-06-26 Num(3o)