How to change microphone component output file name

I’ve have some success with code like this:

Begin Experiment

renameRecordings = []

End Routine

old_file = os.path.join("data", micRecFolder, 'recording_mic_%s.wav' % tag)
new_file = os.path.join("data", micRecFolder, '%d%s_%s_%d.wav' % (score,Correct,expInfo['participant'],trials.thisN))
renameRecordings.append([old_file,new_file])

End Experiment

for Idx in range(len(renameRecordings)):
    # Check file size
    if os.stat(renameRecordings[Idx][0]).st_size > 0:
        # Rename files
        os.rename(renameRecordings[Idx][0],renameRecordings[Idx][1])
    else:
        # Delete empty files
        os.remove(renameRecordings[Idx][0])
2 Likes