############################
#
#  Resamples all the files in a specified
#  directory to have the same sampling 
#  frequency.  Files are saved in specified
#  directory.
#
############################


form Resample files
	comment Directory of sound files
	text sound_directory C:\Users\ran\Desktop\2-更改采样率脚本\Angola\
	sentence Sound_file_extension .wav
	comment Save resulting files in which directory
	text end_directory C:\Users\ran\Desktop\2-更改采样率脚本\Angola\new\
	comment Resample to which frequency
	positive sample_frequency 22050
endform

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

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

for ifile from 1 to numberOfFiles

	# A sound file is opened from the listing:

	filename$ = Get string... ifile
	Read from file... 'sound_directory$''filename$'

	# Resample

	Resample... sample_frequency 50

	# Save resulting file

	Write to WAV file... 'end_directory$''filename$'

	select all
	minus Strings list
	Remove
	select Strings list
endfor

select all
Remove

