SoX save output to the input filename

Viewed 19

I have been using commands like sox input.wav output.wav reverb 50 50 100. How can I override the input file? In other words, I want to read from let's say audio.wav and apply reverb to that and save it as audio.wav. I have messed around with different flags from the documentation, but I cannot get any of them to work. When trying the naive sox audio.wav audio.wav reverb 50 50 100, I get Premature EOF on .wav input file. Any help would be appreciated. Thanks.

1 Answers

SoX does not offer the possibility to overwrite the input file.

This has the benefit of always leaving you with a backup afterwards. If processing of a large audio file would crash halfway through, then you will not be left with a half-finished file. Just discard the output file and try again.

If you see no value in keeping the original file, then just throw it away and rename the new file.

sox input.wav output.wav reverb 50 50 100 && mv output.wav input.wav

I deliberately used && to separate the two commands, to prevent mv being executed in case SoX fails.

If you need this more often, then just turn it into a Bash script or function.

Related