Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Linux bash script for lossyWAV batch processing (Read 3038 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Linux bash script for lossyWAV batch processing

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 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) 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.