Normalize the wav files through scripting

I have created a macro named “Normalize_wav_files”. To handle that through scripting I see a script id “Apply Macro:”. I am using following script “https://github.com/audacity/audacity/blob/master/scripts/piped-work/pipe_test.py” but didn’t get how to apply a macro through scripting. I have nearly ~1000 wav files and I want to normalize those wav files through script. Please help me in how to achieve that

It would be much easier to batch process your files with an Audacity “macro”.
See: https://manual.audacityteam.org/man/macros.html

This shows a macro that can normalize a batch of files and export the processed files to a “macro-output” folder.

Screenshot_2022-10-26_13-41-33.png

Thank you for the quick response steve. I just want to know is there any way we can automate this batch process?

Because I have 1700 wav files divided among nearly 30 folders. Doing through folder by folder is a time consuming process and sometimes we have to do normalization on same with different parameters. In order to do that we have repeat the same process on all 30 folders.

Just I am curios to know if any automated procedure available around this. Please let me know if you any other suggestion to achieve this bit more easily. Thank you!!

To date I have not written a Nyquist script, but I am thinking that Import2 and Undo, coupled with the commands from Steve’s macro might be the start of a Python script to do this. If that works, I imagine you could add a list of all the directories and file names you wished to process.

There are several potential issues with this approach, so it might be easier just to run the macro 30 different times. :wink:

Another approach might be to simply collect all of the files into one folder, process that folder with Audacity’s macro facility then use a shell script to redistribute the output files. This is probably the way I would go. :smiley:

A similar approach that I’ve used (on Linux, I’m not sure if it would work on Windows), is to make a temporary folder somewhere convenient, and put into it symbolic links to all of the files that you want to process. The actual files may be in any directory, anywhere on the system. The exported files will take the name of the link, which provides a useful workaround for handling multiple files with the same file name. The other nice thing about this method is that symlinks take up virtually no space and can be created almost instantly, irrespective of how big the file is (a symbolic link just points to the file).

and yes, it would probably be quicker (and certainly easier) to apply the macro 30 times than to write, check, test and run a Python script to automate the entire process.

If I really did need to automate the entire process (for example, if this was going to be a regular task), then I’d probably use SoX rather than Audacity (https://sox.sourceforge.net/).

It’s possibly a bit off-topic for this forum, but if you want to take this approach, I found i little tutorial that may be helpful: SoX tutorial: Batch processing audio on the command line