exporting clips start and end time-codes

Hello all!.. from a newcomer…

here on:
Ubuntu 22.04.1 LTS
using : audacity-linux-3.2.2-x64.AppImage
I have been using Audacity years ago on a Free radio, nice times! I’m back !

I am asking for a feature, not sure it’s not here already, but I could not find it (not using the right words, maybe…)

My context, in short : I have interviews in an african language, the transcribed text in african, a translation of this text.
Interviews are in short sequences of two or three sentences, wav files.
I need to export start and end time of each file (clip) to build some sort of subtitle text file (for those who know: srt format like)
This then goes into a linguist tool call Elan with more stuff, not just subtitles: grammar annotations etc.

Here is how I do it for now, you may have much better ideas on how to do it:

I import those files and merge them in sequence (manually), so I have clips: itw01, itw02,itw03…itw50
For each clip I can see at the bottom of the script start and end times.
But I cannot copy paste those time codes.

Here is the hard part; I start to build a file with itw index and times codes, typing them manually:
32-15 00:02:19.729 00:02:32.477
32-16 00:02:32.477 00:02:39.451
32-17 00:02:39.451 00:02:46.269

I know all the information is there in Audacity: itw index is the file/clip name, time codes…

Is there a way, a menu, a utility, which could save me time (and errors!)

Thanks for help and advice!

I found a workaround!
The whole process can be done easily using Python and pydub
(check: https://github.com/jiaaro/pydub )
So, I did not need Audacity for that, not this time around!

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import os
import re
import sys
import pydub

def timecode(m):     # returns timecode formatted as a string "00:00:00.000"
	secs=m/1000   # float
	mns=int(secs/60)
	h=int(mns/60)
	mn=mns-h*60
	s=secs-mns*60
	return f"{h:02d}:{mn:02d}:{s:06.3f}"

# all input files in same directory, name structure XX-YY.mp3 with XX fixed and YY incremental
# resulting wav file as XX-ref-timecodes.csv (tab separated values) and XX.wav

# might run on several directories, starting from current

for dirname, dirnames, filenames in sorted(os.walk('.')):
	if '.git' in dirnames: dirnames.remove('.git') # don't go into any .git directories.

	tmillis=0
	end=timecode(tmillis)
	taudio=pydub.AudioSegment.empty()
	fout=open("XX-ref-timecodes.csv","w")
	fout.write("ref@B\tstart\tend\n")


	for filename in filenames :
		select=".mp3"
		
		if select in filename :
			mp3file=filename[:-4]
			audio=pydub.AudioSegment.from_mp3(filename)
			millis=len(audio)  # length in milli-seconds
			start=end
			tmillis+=millis
			end=timecode(tmillis)
			print(mp3file,start,end)
			fout.write(mp3file+"\t"+start+"\t"+end+"\n")
			taudio+=audio

	fout.close()
	if tmillis>0:
		prefix=mp3file[:2]
		taudio.export(prefix+".wav", format="wav")
		os.rename("XX-ref-timecodes.csv",prefix+"-ref-timecodes.csv")
		print("* files ready *")
	else:
		os.remove("XX-ref-timecodes.csv")