Jump track to selection

Hi there,

I’ve been selecting a portion of a track in a dialogue with a mike bump or low level error using Export Selected Audio and then removing the issue in RX8 Standard. I export the track and import it back into Audacity which puts it as a new track on the left of Audacity at the beginning. I then manually drag the track to the place where the original mistake is and I replace it with the repaired version. As it takes quite a long time to drag and position the new track, I was wondering if there was a way of speeding up the dragging using labels e.g creating a label selection when exporting a section and then being able to jump to that selection with the new track using a macro. Is this possible? I hope that makes sense?

Best wishes


See this post for another suggestion to overcome this issue: Time Shift Tool → Clip Handles

Hi jademan,

Thank you for your reply. I would have replied yesterday, but couldn’t login to the forum for some reason. Anyway, I wrote a couple of macros which have helped. The first is:

01 Move focused Track to Top
02 Add label at Selection
03 Move Focus to Previous and Select
04 END

I then go to FIle/Export/Exported Selected Audio (Annoyingly, this is not one of the macro commands). Next I used RX8 Standard for some audio repair and import the results back into Audacity. I then run the second macro which is:

01 Select Track Start to End
02 Cut
03 Move to Next Label
04 Paste
05 Move Focused Track to Top
06 Cut
07 Closed Focused Track
08 END

Then I drag over the original section of audio which contained the mistake I wanted to remove between the two yellow vertical lines created by the label selection and paste in the new repaired section. I was trying to work out if it were possible to add more steps to the second macro to do this automatically? I played around for a while trying different commands, but couldn’t find a better solution. Any advice would be much appreciated.

Best wishes


I made this video to explain the issue I’m having https://youtu.be/vOnYDFCsMa8 I hope someone can make some suggestions for improving the macros further.

Assuming that the track that you are working on is at the top of the project, how about something like this:

Export Selection:

Export2:Filename="<full path to suitable folder>/temp.wav" NumChannels="1"

(Set NumChannels to “2” if working on a stereo track - you could have 2 versions of this macro if you frequently switch between mono and stereo)

Import and replace:

Import2:Filename="<full path to folder>/temp.wav"
SelectTracks:Mode="Set" Track="0" TrackCount="1"

Hi Steve,

Thank you so much for jumping in as always. How do I add what you’ve written to the two macros I’ve already put together?

Best wishes


If you’re using a recent version of Audacity, just import these two macro “.txt” files into the Macro Editor.
Export Selection.txt (71 Bytes)
Replace.txt (153 Bytes)
Then modify the file paths to somewhere that is valid on your computer.

Note that on Windows, the file path will probably need to use either double back-slashes or forward slashes rather than the usual single back-slash. For example this will (probably) fail because of the single back-slashes:


So you would probably need to use:




Hi Steve,

Thank you! I’ve imported the txt files and put in the path. When I run the first macro, I get a Long Message prompt appearing saying Exported to WAV format: C:\Users\Joe\Desktop/temp.wav. Presuming I then edit the audio using RX etc, I would need to overwrite the temp file with the same name and then in Audacity run the second macro without needing to click Import/Audio. Is that right? I was surprised I didn’t see a message about the fact I already had a file with the same name on my desktop and did I want to replace it. Also do I need to have the long message prompt appearing?

Also what would the file path be on Mac?

Thank you so much for your help.

Best wishes



“Export2:” was designed specifically for use in macros and scripting. It is intentional that it allows a file to be overwritten (it’s much more useful this way).

Yes, but you can just move it out of the way. If you leave it open and just move it out of the way, a new message will be added to that message box each time you use the “Export Selection” macro.

The exact path isn’t important. It just needs to be somewhere that you have read + write permission, with sufficient free space.
Like Linux, macos uses a forward slash character (“/”) as the path separator.
Of course the path and file name must be the same in both macros.

Thank you so much Steve for all your answers. You’re amazing! These two macros should prove really useful for edting. I’ll get back to you if there are issues with making this work on my Mac.