The way Praat works with directory listings is with the Strings
object. You can generate a Strings
object with names of files or of directories, and then loop through those to open each individual file and process it in whichever way you prefer.
As for the output, you could manually output to a text file, or you could save the results of your analyses in a Table
object, that can then be saved as a csv
or txt
as you prefer. You can see this in action in my related answer.
In this case, what you want is something like this
form Process files...
sentence Path /path/to/your/files
endform
# Optional: make sure the path has a trailing slash
path$ = if right$(path$) = "/" then path$ else path$ + "/" fi
output = Create Table with column names: "output", 0,
... "file mean_pitch"
files = Create Strings as file list: "files", path$ + "*wav"
total_files = Get number of strings
for i to total_files
selectObject: files
filename$ = Get string: i
sound = Read from file: path$ + filename$
# Run whatever kind of analysis you want here
# For example, get the mean pitch for each file
pitch = To Pitch: 0, 75, 600
mean = Get mean: 0, 0, "Hertz"
selectObject: output
Append row
row = Get number of rows
Set string value: row, "file", filename$
Set numeric value: row, "mean_pitch", mean
removeObject: sound, pitch
endfor
selectObject: output
Save as comma-separated file: path$ + "output.csv"
removeObject: files, output