# Script to print label, tier, beginning and end time for all intervals in a textgrid # by turning the textgrid into a table # for all textgrids in a folder (tables are appended to form one table for all textgrids) # Anja Arnhold 09/2014 form Input comment Give file location. Output file will be saved in the same folder. sentence Path YourPathAndFolderHere sentence Name_of_output_file WithoutFileExtension endform # Open textgrids Create Strings as file list... list 'path$'/*.TextGrid head_words = selected("Strings") file_count = Get number of strings for current_file from 1 to file_count select Strings list filename$ = Get string... current_file Read from file... 'path$'/'filename$' name_only$ = filename$ - ".TextGrid" select TextGrid 'name_only$' Down to Table... yes 6 yes yes select Table 'name_only$' Append column... Filename nrows = Get number of rows for k from 1 to nrows Set string value... k Filename 'name_only$' endfor Rename... Intervals'current_file' if current_file > 1 previous = current_file - 1 if current_file = 2 select Table Intervals'previous' plus Table Intervals'current_file' Append select Table appended Rename... IntervalsTo'current_file' else select Table IntervalsTo'previous' plus Table Intervals'current_file' Append select Table appended Rename... IntervalsTo'current_file' endif endif # Remove textgrid select TextGrid 'name_only$' if current_file = 2 plus Table Intervals'previous' plus Table Intervals'current_file' elsif current_file > 2 plus Table Intervals'current_file' plus Table IntervalsTo'previous' endif Remove endfor select Table IntervalsTo'file_count' Save as tab-separated file... 'path$'/'name_of_output_file$'.txt select 'head_words' plus Table IntervalsTo'file_count' Remove clearinfo echo Done! 'file_count' files measured.'newline$'