Keep only the middle part of a soundfile using macro


I have many sound files which are made out of something like: music_1…silence…music_2…silence…music_3
My goal is to export only the middle part of every file (here music_2) and discard the rest by using a macro. I used the “sound finder” which detected the different parts very well. But now I don’t know how to move on. Could someone please give me a hint what I have to add in the macro to make things work? Thank you in advance!


Why do you need to use a Macro rather than just using “Export Multiple”?

I want to run this command on over 200 audio files. I don’t think that “Export Multiple” is really helpful because when I am using this, I have to run the required commands manual previously.

Do each of those files contain the same number of “music” parts?

If not, then it will not be possible to do this with a “normal Macro”. A normal Macro is just a list of commands. If you don’t know in advance how many music parts there will be, then you can’t create a list with the right number of Export commands. The solution in this case would be to use a more advanced form of scripting, either as a “Nyquist Macro” (see: Nyquist-Macros - Audacity Manual) or using “Python scripting” (see: Scripting - Audacity Manual but note that mod-script-pipe is included in Audacity 2.3.2 by default, so you don’t need to install it separately, just enable it in Preferences).

Both Nyquist Macros and Python Scripting are quite “advanced” topics because you need to know a bit about Nyquist or Python programming. It would probably be quicker to just use Export Multiple manually (200 times) than to learn enough about advanced macros to be able to program the job. However, if you still want to try programming it, then we can help. The first thing would be to decide whether to use Nyquist or Python. If you already know some Python, then Python will probably be your best choice, otherwise Nyquist will probably be the better choice.

Thank you for your answer!

There are exactly three music parts in each file (and I need the second part each time), but the lengths of the different parts differ from file to file. Therefore I can not simply cut away x seconds at the start and the end of each file. So is there a way to automate this process with a “normal Macro”?

Yes you can do that in a normal Macro.
To export the second labeled region would be something like this:


Note: The first “Undo” undoes the “Align Start to Zero” command. The second “Undo” undoes the “Trim” command.

Thank you very much!
With your help I got it working finally.