I need to cut off the first say 3 seconds from a batch of wav files. Is there a way to do it from the command line or using a linux native program?
Thanks.
I need to cut off the first say 3 seconds from a batch of wav files. Is there a way to do it from the command line or using a linux native program?
Thanks.
You can use sox (see man sox for its options) to process one file:
sox music.wav shortermusic.wav trim 3
The timing value is hours:minutes:seconds, defaulting to the smallest interval(s) if parts are omitted, so here we can use 3 for three seconds.
After that it's just a case of using a loop to iterate across the set of files
mkdir trimmed
for m in *.wav
do
printf 'Trimming: %s\n' "$m"
sox "$m" trimmed/"$m" trim 3
done
The trimmed files will be put into a subdirectory trimmed so that you don't get to trim them twice, accidentally
If you have ffmpeg installed you can visually check the duration of a file:
ffprobe music.wav 2>&1 | grep Duration
or a little more elegantly in seconds:
ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 music.wav