Exporting indices

Do you mind sharing your script? I’m looking for the exact same thing.