Designs Edge
Designs Edge

Reputation: 1

Bash script to extract first seconds and rename mp3 files in folder

I have a folder with several MP3 files that I need to extract 10-15 seconds of audio from. I would also like to rename these by appending sample-(name).mp3 to the converted files. How can I do this via Shell Script? Thanks in advance!

Upvotes: 0

Views: 475

Answers (3)

Designs Edge
Designs Edge

Reputation: 1

Thanks to a user on Linux pages - got this bash script, works perfectly. Thanks to everyone for helping me with this, greatly appreciated!

#/bin/bash

for i in *.mp3 do mp3splt "$i" 00.00.00 00.10.00 -o sample-"${i%.mp3}" done

Upvotes: 0

rama
rama

Reputation: 201

You need a tool like ffmpeg to accomplish this. There are other tools like mp3split as well.

You can script something like this.

for each infile in the directory:

ffmpeg -t 15 -i infile.mp3 -acodec copy sample-$infile.mp3

Upvotes: 2

user4284354
user4284354

Reputation:

Hu, I don't now how you can extract exactaly 10/15 seconds of your file(.mp3), but you can use the program named xxd in order to read a part of the file in hexadecimal format and copy this in a new file named sample_name... try to write a little script and i try to help you.

Upvotes: 0

Related Questions