Split large amount of wav files to small parts

9,888

This is mentioned as an example in man sox:

split the input file into multiple files of 30 seconds in length. Each output filename will have unique number in its name as documented in the Output Files section.

sox infile.wav output.wav trim 0 30 : newfile : restart

So, assuming your wav files are under directory ~/myfiles, and you want to create the split versions in ~/split you can do

mkdir ~/split
cd ~/myfiles
find . -name '*.wav' \
 -exec sh -c 'mkdir -p ~/split/$(dirname "{}")' \; \
 -exec sox {} ~/split/{}  trim 0 10 : newfile : restart \;
Share:
9,888

Related videos on Youtube

Taron
Author by

Taron

Updated on September 18, 2022

Comments

  • Taron
    Taron over 1 year

    I have large amount of wav files (over 50 000) and I need to split every wav file to 10 second long parts.

    t's nearly impossible to do it one by one, so my question is: How can I do it in ffmpeg (or in sox)?

  • Taron
    Taron over 7 years
    there is a problem, i don't know, how sox works :( ... and i don't know how to use this command... if my exact source folder is named e.g.: "3_6_5_2016_L" should i write to command script cd 3_6_5_2016_L or ~/3_6_5_2016_L ... i'm really amateur but i desperately need to split these files :( ... here is a link for screenshot of the error which it shows: leteckaposta.cz/331694478 (im czech so don't get scared of the language, it's not some click bait, just click on SOX_screenshot.jpg link...) please, if you can, write the instructions like you would for a dummy :) thank you so so much
  • meuh
    meuh over 7 years
    I am not able to access that website. If you have an error message you should copy it as text. If you have to post an image, edit your original question using the "image" button in the web page edit form and it will be held in the standard stackexchange place, namely imgur.com
  • Taron
    Taron over 7 years
    I already added a screenshot directly into my question
  • meuh
    meuh over 7 years
    Your screenshot shows that you are not using a Unix Operating System, but microsoft Windows. My answer will not work for you. You need to ask your question again on another site such as stackoverflow, making sure you mention you are using Windows.