1

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
J.Baoby
  • 2,167
  • 2
  • 11
  • 17
vicki
  • 157
  • 2
  • 23
  • Please go back to dostips and reply that your question has been solved. – Squashman Nov 26 '16 at 19:06
  • 1
    Possible duplicate of [How do you trim the audio file's end using SoX?](http://stackoverflow.com/questions/9667081/how-do-you-trim-the-audio-files-end-using-sox) – joelostblom May 19 '17 at 11:30

2 Answers2

3

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.

dbenham
  • 127,446
  • 28
  • 251
  • 390
1

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"
)
J.Baoby
  • 2,167
  • 2
  • 11
  • 17