rename command with external variable
I have the following bash script which accepts an argument, creates a directory with the name of the arg, rips a cd putting all files in the new directory and then compresses them. I want to rename all the created files to have the name of the arg but I can't figure out how to use a variable in the rename command. Here is my script:
#!/bin/bash
E_WRONGARGS=85
case "$1" in
"" ) echo "Usage: `basename $0` new-folder"; exit $E_WRONGARGS;;
* ) ffolder=$1;;
esac
mkdir ~/Music/$ffolder
cd ~/Music/$ffolder
cdparanoia -B
rm *00*
rename 's/\.cdda//' ~/Music/$ffolder/*.wav
#rename 's/track/$ffolder/' ~/Music/$ffolder/*.wav
oggenc -q 5 *.wav
eject /dev/cdrom
exit 0
The second rename command which is commented out is one of my failed attempts. I also tried putting {} around $ffolder and I tried making the whole regex expression a variable all to no avail. If someone could show me how to do this properly I would greatly appreciate it.
|