Script to Batch Export .XRNS

Hi, I am trying to take a large (>1000 item) list of .mod files and export each one to .xrns using the

renoise.app():load_song and

renoise.app():save_song_as

functionalities. It works successfully for a single song, but when I try to do it iteratively in a for loop the saving part is so much faster than the loading part that it always saves the first song loaded with the new filename.

I think what I need (and I’m totally not sure, this is my first time using Lua or Renoise) is an observable that notices when load_song has finished. I couldn’t find such a thing in the API. Do you have any suggestions?

Many thanks!