If this template helps then use it. If not then just delete and start from scratch.
MacOS 14.6
PsychoPy 2024.2.0+
Standalone
I’m out to rename WAV files to make them useful and easily dealt with after the fact.
I’ve been able to make this work just running the experiment under an older version (2024.1.0 works), but it is my understanding that the way Mic recordings are handled has changed (I assume with 2024.2.0). It seems to now generate the WAV files and store then immediately which is a huge improvement, but it goofs the way I have typically renamed files.
Here is what works in prior versions:
Before experiment
# rename recordings set up
renameRecordings = []
End routine containing Mic component [It has seemed to matter that this go physically below the Mic component within the routine]
# Create new recording names
old_file = os.path.join("data", micRecFolder, 'recording_mic_%s.wav' % tag)
new_file = os.path.join("data", micRecFolder, '%s_%s_%s_%s_%s.wav' % (expInfo['participant'],vowel,block_no,trial_no,item))
renameRecordings.append([old_file,new_file])
End experiment
# actually do the re-naming
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])
That seems to work in versions <2024.1.0. In later versions, that arrangement spits out a filename error–Can’t find the file. I tried moving it all to End Experiment, which was promising, but it only changed the first file name. I stopped there and figured I’d ask.
This is more informational for myself and others-- what would be the best way to go about handling this task? Additionally, bonus points if you can tell me precisely what tag
as I use it in working with the old file name references. I assume it’s the autogenerated file name, but I’m not 100% sure.