# Anja Arnhold 08.08.2016 # This script reads all files from a folder and prints out their # total durations (in ms, rounded to two decimals) in a text file form Read files from folder sentence Sound_source_directory YourPathAndFolderHere sentence outputfile sound_file_durations NameWithoutExtension sentence outputfilelocation YourPathAndFolderHere comment What is the extension of the files? word ending .wav comment Do you want to measure durations? boolean MeasureDurations 1 endform # Create file list Create Strings as file list... list 'sound_source_directory$'/*'ending$' select Strings list file_count = Get number of strings # Open files for current_file from 1 to file_count select Strings list filename$ = Get string... current_file string$ = filename$ - ending$ Read from file... 'sound_source_directory$'/'string$''ending$' if measureDurations = 1 duration = Get total duration endif # Write the file name and duration into a line of the text file if measureDurations = 1 text$ = "'string$''tab$''dur:2''newline$'" else text$ = "'string$''newline$'" endif text$ >> 'outputfilelocation$'/'outputfile$'.txt if ending$ = ".wav" select Sound 'string$' Remove elsif ending$ = ".TextGrid" select TextGrid 'string$' Remove endif endfor # End of for looping through all files in the list select Strings list Remove