HydrogenAudio

Lossy Audio Compression => Other Lossy Codecs => Topic started by: doccolinni on 2010-03-27 16:37:27

Title: Linux bash script for lossyWAV batch processing
Post by: doccolinni on 2010-03-27 16:37:27
I'm a Linux user and, unfortunately for me, lossyWAV doesn't support wildcards in filenames so I had to manually process one file at a time with it. Eventually I got bored of doing that (plus today I had to process nearly 1000 files with lossyWAV...), so I decided to write a bash script that does it for me. I figured it might be useful for anyone else who uses Linux and lossyWAV, so I decided to share it. Here it is:

Code: [Select]
#!/bin/bash

for dat in *
do
    printf "\n"
    wine lossyWAV.exe "${dat}" -t -i -q 4
done

exit


Of course, "-t -i -q 4" is my personal choice of lossyWAV settings so adjust those to your liking. Here are instructions on how to use the script:

1) Of course, you need to have Wine (http://www.winehq.org/) installed.

2) Copy lossyWAV.exe to ~/.wine/drive_c/windows/system32 ("~" is your home directory, i.e. you need to copy lossyWAV.exe to /home/[YOUR USERNAME]/.wine/drive_c/windows/system32 ). I highly recommend copying libfftw3-3.dll (from this archive (http://ftp://ftp.fftw.org/pub/fftw/fftw-3.2.2.pl1-dll32.zip)) to the same directory for greater processing speed.

3) Copy-paste the script I posted in a text editor, adjust the command-line lossyWAV settings to your liking and save it as lossywavproc.sh (you can choose a different filename, it's not important).

4) As a super-user copy the lossywavproc.sh to /bin but make sure to adjust the permissions so anyone can run the script.

5) In terminal, go to the directory which contains the .wav files you want to process with lossyWAV.

6) Type lossywavproc.sh (or whatever you've named it) and hit enter.

Any non-wav files in the directory will be left untouched (although you will get an error saying "File type is not RIFF" but you don't have to worry, the script won't get stuck and will continue processing any .wav files in the directory until it's done.



If you want the script to automatically convert the files to lossyFLAC, use this script instead (but you need to have FLAC installed as well, obviously):

Code: [Select]
#!/bin/bash

for dat in *
do
    printf "\n"
    wine lossyWAV.exe "${dat}" -t -i -q 4
done

printf "\n"

flac --keep-foreign-metadata --replay-gain -8 -b 512 *.lossy.wav

rm *.lossy.wav

exit


Of course, adjust the lossyWAV and FLAC command-line arguments to your preferences.



Cheers.