In Macro, the select command does not work in "add" and "remove" modes

Hi

I am using Audacity 3.1.0, on Windows 10 Home, 64 bits.

I have a set of 200+ mp3 files in which I want to delete the intro and outtro parts.
So I want to select first 29 seconds and the last 41 seconds, and then trim them.

Since this is my very first macro, I wanted to check if my macro selects the regions properly.
(If this works, I will add more lines to delete the selection and export the file.)

So, I created the following macro:

01 Select End = “29” Mode = “Set” RelativeTo = “ProjectStart” Start = 0
02 Select Mode = “Add” RelativeTo = “ProjectEnd” Start = “41”
03 -END-

But when I run this macro, line#01 has no effect: the final selection is as defined in line#02.
In other words, line#02 does not ADD its own selection to the selection created by line#01.

To test this further, I tried the following variations:

  1. Changed the mode in both lines to “Add”, so that the selections are added.
  2. Interchanged the lines, where the first line is in “set” mode and the second line is in “add” mode.

In both cases, the final selection is as defined in the second line only.

So I conclude that the first line actually does its job, but the second line replaces that selection with its own, rather than adding it to the first selection. [BUG]

In other words, the Add mode does not work.


Having found this problem, I tried another macro:

01 Select all
02 Select Mode = “Remove” RelativeTo = “ProjectEnd” Start = “41”
03 -END-

I expected this macro to first select the whole track and then deselect the last 41 seconds.
But nothing is selected.

01 Select all
02 Select End = “29” Mode = “Remove” RelativeTo = “ProjectStart” Start = 0
03 -END-

In this case also, nothing is selected.

That means the “remove” mode also does not work as expected.


I created three separate macros, in which I entered only one line at a time (Select from the start, select from the end, select all).
All three macros work perfectly.

Thus there is no problem with the lines themselves.
It’s the combination that does not work.

Try this:

SelectTime:End="41" RelativeTo="ProjectEnd" Start="0"
Delete:
SelectTime:End="29" RelativeTo="ProjectStart" Start="0"
Delete:
ExportWav:

Thanks for the prompt reply!

I set the Macro output directory to D:\Downloads, and then restarted Audacity.

I replaced the Select command with the Select Time command, and deleted the Select all command.
But I retained the Export as mp3 command, because I do not want to export the file as a wav file.
The modified macro can trim the file, but cannot export the mp3.

On the other hand, I can export the trimmed file as mp3 using the File > Export > Export as mp3 menu option.
So I am not clear why the macro cannot export.

BTW could you please clarify the difference between Select and Select time commands?
Both appear to be identical!

Try running the “MP3 Conversion” macro. Does that create MP3 files in "D:\Downloads\macro-output"?

The “Select” command has more options. See: Extra Menu: Scriptables II - Audacity Manual and Extra Menu: Scriptables I - Audacity Manual

Try running the “MP3 Conversion” macro. Does that create MP3 files in "D:\Downloads\macro-output"?

All the mystery is resolved!
I checked in the path, and indeed, the exported file is there already.

But I find that there are two problems in this logic:

  1. I never expected a subfolder called “macro-output” to be created.
    When I set the path, all the files should be created right there, not in a sub-folder.
    If the user wants to create a new subfolder, let him explicitly define that while setting the path.
    This is how all other software work.

  2. If I run the same macro for the second time, it should pop up an error message: This file already exists- Overwrite? [Y/N]
    This also does not happen: The file is replaced without any warning.

In the manual (Apply Macro - Audacity Manual) it says:

The exported files will be saved in a folder named "> macro-output> " in the folder specified in the > Macro output > field in Directories Preferences. The original files are > not > altered.

I believe the reason for this is to avoid accidentally overwriting the original files.


Batch processing is intended to run on the selected files without requiring additional user input so that you can set it running and leave it until it has finished.
Personally I’d prefer there to be an option in Preferences to choose from:

  • Overwrite (overwrites without prompting)
  • Prompt (interrupt the batch process until the user has confirmed overwriting or supplied a new name)
  • Auto-rename (if the file already exists, append a number: filename-01, filename-02, …)

Personally I’d prefer there to be an option in Preferences to choose from:

  • Overwrite (overwrites without prompting)
  • Prompt (interrupt the batch process until the user has confirmed overwriting or supplied a new name)
  • Auto-rename (if the file already exists, append a number: filename-01, filename-02, …)

Lovely!

In fact, I’d like to see an additional option:

  • Save the converted file in the original source folder

(This way, we have the choice to overwrite the original, or save the converted file with some prefix/suffix that links it clearly with the original.)

So the question is, how do we submit this as a proposed new feature?
(I actually thought you are the developer, so it is up to you to take the inputs right from this thread!)

I’m always concerned about “support issues”. Allowing files to be overwritten in batch processing is potentially very dangerous. If Audacity added this option, I doubt it would be long before we received cries for help from people that had accidentally overwritten (possibly hundreds) of their files, and once overwritten the originals would be unrecoverable.

For users that really do want to overwrite their original files, it’s trivial to drag the processed files over into the original directory.

I would like to see an option for the “macro-output” folder to be in the original source folder - Audacity used to do this, and I think it would be a good default.


We have an “adding features” section on this forum: Adding Features - Audacity Forum
I’m not sure how much (if any) attention that gets from the new development team, but it’s a good place to discuss ideas for new features.

I think the best place to get the attention of the developers is on GitHub (in the “Issues” section): GitHub - audacity/audacity: Audio Editor
Posting there requires a (free) GitHub account. I’ve already got an account, so I’ll be happy to post a Feature Request issue there when we have finished discussing this matter - perhaps you would like to summarise here what the feature should be?


I am “a” developer, though I’m mostly retired from working on the main Audacity app. Audacity has had dozens of developers / contributors over its 20+ year history. I still do some Nyquist Plug-in development, and of course some end user support here on this forum :wink:

I’d say that you had summed it up nicely.

Kindly take this up at GitHub. Thanks a lot!

I’ve logged the issue here: https://github.com/audacity/audacity/issues/2168