Re: bash script to convert, compress
On Thu, Dec 27, 2012 at 05:47:57AM -0500, tsitras@linuxmail.org wrote:
> Hi. i am running debian 6.0.6 and i am banging my head to create a simple script that will run periodically (through cron).
> i do have a whole lot of wav files in opt/wavfiles and i do need:
> -convert them to mp3
> -delete the wav files that have been converted to mp3
> -compress the files and move the compressed file to /opt/mp3backups
> is there a simple script ready for the job?
To get you started:
for file in /opt/*.wav; do
oggenc -q 4 $file && rm $file
done
# forget about compressing the files because they're already compressed
mv *.ogg /opt/mp3backups
Note that I use oggenc here, because I'm not familiar with the command
to convert to mp3, although I imagine ffmpeg would do it. If you find
you need to specify an output file name, you could do it like this:
$(basename $file wav)ogg
That would remove the 'wav' extension from $file and replace it with an
'ogg' extension.
You might want to specify a working directory for the script to run in.
Maybe start it off with:
cd /tmp
Others here might have an opinion on that.
-Rob
Reply to: