0

How do I change the sample rate for every file in the folder?

The following code converts the files, but it erases the file. After this command, every wav file is empty.

for i in wav/*.wav; do
    sox -r 8000 -e unsigned -b 16 -c 1 "$i" "$i"
done

How do I run the code to every file in the directory?

Yuri Burkov
  • 141
  • 10
  • 1
    I don't know `sox`, but I'm guessing you're trying to write to the same file you're reading, and that truncates the file - see [this Q&A](https://stackoverflow.com/q/6696842/3266847). – Benjamin W. Aug 19 '20 at 03:31

1 Answers1

1

Something like:

for i in wav/*.wav; do
    sox -r 8000 -e unsigned -b 16 -c 1 "$i" "$i_modified"
done
PatriceG
  • 3,851
  • 5
  • 28
  • 43