########################
#
#  This script takes all the sound files in a selected
#  directory and concatenates them into a single sound
#  file.  The final file is saved as specified.
#
########################

form Concatenate sound files
	comment Directory of input sound files
	text Sound_directory C:\temp\
	sentence Sound_file_extension .wav
	comment Save the final file as
	text Save_as C:\temp\temp.wav
endform

# Here, you make a listing of all the sound files in the specified directory.

Create Strings as file list... list 'sound_directory$'*'sound_file_extension$'
numberOfFiles = Get number of strings

for ifile to numberOfFiles
	select Strings list
	filename$ = Get string... ifile

	# A sound file is opened from the listing:

	Read from file... 'sound_directory$''filename$'
endfor

# Now, concatenate all files into a single file

select all
minus Strings list
Concatenate

# And save the resulting file

Write to WAV file... 'save_as$'

select all
Remove
