Author Topic: Converting all you wave files to the right format  (Read 3164 times)

Offline widdly

  • *
  • Posts: 27
    • View Profile
Converting all you wave files to the right format
« on: October 10, 2019, 05:14:56 pm »
I've got loads of wave files from all over the place.  I find it annoying when I copy them onto my MV8800 and lots are in an unsupported format. 

If you are running linux or have ubunutu installed under windows 10 ( You are not allowed to view links. Register or Login ) you can try my script.

First you need to install sox.

Code: You are not allowed to view links. Register or Login
sudo apt-get install sox
sudo apt-get install libsox-fmt-mp3

I create a file ./conv.sh in the top level directory containing my wave files..

Code: You are not allowed to view links. Register or Login
#!/bin/bash
# convert wave file to 44100 16bit and normalize
if [ ${1: -4} == ".wav" ]
then
#       sox --info "$1"
        sox "$1" -r 441000 -b 16 --norm "$1"_tmp.wav
        rm "$1"
        mv "$1"_tmp.wav "$1"
fi

I then execute the script on all the wave files in the sub-directories below..

Code: You are not allowed to view links. Register or Login
find . -maxdepth 5 -mindepth 1 -type f -exec ./conv.sh {} \;
This will convert and normalize all *.wav files to 16bit 44100kHz files.  You can extend the script to convert mp3 files or whatever other formats you might have.  If you are testing or fiddling with the script then it is probably best to backup your waves in case you make a mistake.


Offline widdly

  • *
  • Posts: 27
    • View Profile
Re: Converting all you wave files to the right format
« Reply #1 on: October 10, 2019, 10:48:13 pm »
If you have a bunch of WAV files you can rename them to .wav using the following commands...

Code: You are not allowed to view links. Register or Login
find -name "*.WAV" -exec rename 's/\.WAV/.waver/' {} ";" 
find -name "*.waver" -exec rename 's/\.waver/.wav/' {} ";" 

I had to do this because the script above only works with .wav

Offline keefaz

  • *
  • Posts: 49
    • View Profile
Re: Converting all you wave files to the right format
« Reply #2 on: October 11, 2019, 05:52:48 am »
Nice, but why not output converted files to a subdirectory this way you still have the original files...

Code: You are not allowed to view links. Register or Login
#!/bin/bash
# convert wave file to 44100 16bit and normalize
if [ ${1: -4} == ".wav" ]
then

  # create .wav file "converted" subdirectory path 
  outputdir="${1%/*}/converted"

  # create subdirectory "converted" into the .wav directory
  # -p option will tell mkdir to ignore if subdirectory already exists
  mkdir -p "$outputdir"

  # convert the file, output to "converted" subdirectory
  sox "$1" -r 441000 -b 16 --norm "$outputdir/${1##*/}"
fi



Offline conecthink

  • Full Member
  • ***
  • Posts: 113
    • View Profile
Re: Converting all you wave files to the right format
« Reply #3 on: October 12, 2019, 03:01:10 am »
thanks for the effort... that can be annoying indeed to have files that dont preview or are unsupported. im on linux but not much of a terminal user though.. i use wavosaur over Wine to selectively convert some unsupported stuff here and there. conceivably i could batch convert the audio files of the entire system but im not going there. 16bit, 44.1 would be a 2 step convert though but i highly recommend wavosaur as a free batch converter that works very well within linux with wine. its an old windows prog, dunno how it runs on win10
 

Offline widdly

  • *
  • Posts: 27
    • View Profile
Re: Converting all you wave files to the right format
« Reply #4 on: October 13, 2019, 03:08:39 pm »
You are not allowed to view links. Register or Login
Nice, but why not output converted files to a subdirectory this way you still have the original files...

That's a sensible idea.   I was working with about 16gb of wave files alreadys on sd card so I wanted to convert in place.

Offline Tresequisovahed

  • Jr. Member
  • **
  • Posts: 65
    • View Profile
Re: Converting all you wave files to the right format
« Reply #5 on: November 07, 2019, 03:28:55 am »
You are not allowed to view links. Register or Login
dunno how it runs on win10
It works perfectly on W10