Reputation: 157
How do I merge the two, so multiple files can be processed, with each file trimmed 15 seconds from beginning, and 15 seconds at the end:
@echo off
cd E:\trim\multiplefiles
mkdir trimmed
rem trims 15 seconds from end of each file, and creates a snipped file in
rem trimmed folder
FOR %%A IN (*.wav) DO sox "%%A" "trimmed\%%~nxA" reverse trim 15 reverse
and
@echo off
cd E:\trim\multiplefiles
mkdir trimmed
rem trims 15 seconds from beginning of each file, and creates a snipped file in rem trimmed folder
FOR %%A IN (*.wav) DO sox "%%A" "trimmed\%%~nxA" trim 15
Upvotes: 1
Views: 1692
Reputation: 130919
The SoX trim effect allows you to specify both start and duration, and a negative duration specifies an end point measured from the end of the file. So sox infile outfile trim 15 -15
will remove the first 15 seconds and the last 15 seconds from the file.
@echo off
cd E:\trim\multiplefiles
mkdir trimmed
rem trims 15 seconds from beginning and end of each file, putting result in trimmed folder
FOR %%A IN (*.wav) DO sox "%%A" "trimmed\%%A" trim 15 -15
Note that ~nx
is not needed in the output specification.
Upvotes: 3
Reputation: 2241
I will assume you can first trim 15 seconds from end of a file, and after that trim 15 seconds from the beginning of the result. Then you can put everything in one loop and use a temporary file like this:
@echo off
cd E:\trim\multiplefiles
mkdir trimmed
FOR %%A IN (*.wav) DO (
rem trim 15 seconds from end and put it in temporary file
sox "%%A" "trimmed\temp_%%~nxA" reverse trim 15 reverse
rem trim 15 seconds from beginning of the temporary file
sox "trimmed\temp_%%~nxA" "trimmed\%%~nxA" trim 15
rem delete temporary file
del "trimmed\temp_%%~nxA"
)
Upvotes: 1