From man 1 sox
[emphasis mine]:
SoX […] has limited ability to split the input into multiple output files.
[…]
SoX's default behaviour is to take one or more input files and write them to a single output file.
This behaviour can be changed by specifying the pseudo-effect newfile
within the effects list. SoX will then enter multiple output mode.
In multiple output mode, a new file is created when the effects prior to the newfile
indicate they are done. The effects chain listed after newfile
is then started up and its output is saved to the new file.
In multiple output mode, a unique number will automatically be appended to the end of all filenames. If the filename has an extension then the number is inserted before the extension. This behaviour can be customized by placing a %n
anywhere in the filename where the number should be substituted. An optional number can be placed after the %
to indicate a minimum fixed width for the number.
It seems the only way to turn this feature off is not to use newfile
.
In your command $(date +%H_%M_%S)
(and the tilde) is expanded by the shell before sox
is started. The tool gets one static pathname without any wildcards it could dynamically interpret (unless ~/
gets expanded to something that includes %n
or so, but apparently this does not happen in your case; if it happened, it would be worse). If you want a single sox
process to output to multiple files then the process has to create different names on its own; I don't think there is a way to make sox
(re-)evaluate date
.
I can think of two methods to do what you want:
Run multiple sox
processes one after another, while splitting the input stream in the right places. (An example of using split
for something similar: here; but it splits by counting bytes, not by detecting silence.) If you manage to do this, then it will be possible to evaluate date
separately for each sox
just before it starts.
Create a bunch of files like you did and rename each afterwards according to its creation time (birth time, btime). Note there are filesystems without support for btime.
date +"%T"
ordate +"%R:%S"
is what you want.