Register
It is currently Sat Dec 20, 2014 8:50 pm

for loop variable


All times are UTC - 6 hours


Post new topic Reply to topic  [ 3 posts ] 
Author Message
 PostPosted: Tue Mar 15, 2011 10:34 pm   

Joined: Tue Mar 15, 2011 10:07 pm
Posts: 2
hi folks...i'm converting audio files with ffmpeg in a for loop. it works but there's a slight problem with the result. the file name extension is in the new file. i'm guessing file name expansion or variable syntax wrong maybe?

Code:
for f in *.flac; do ffmpeg -i "$f" -acodec libmp3lame -ac 2 -ab 128k "$f.mp3"; done


result is inputfile.flac gives me outputfile.flac.mp3.

how can i prevent the .flac in the output file?

thanks


Top
 Profile  
 PostPosted: Tue Mar 15, 2011 11:40 pm   
User avatar

Joined: Sun Jun 27, 2010 12:57 am
Posts: 192
When using bash for a shell you can use:
Code:
for f in *.flac; do ffmpeg -i "$f" -acodec libmp3lame -ac 2 -ab 128k "${f/.flac/.mp3}"; done


Top
 Profile  
 PostPosted: Thu Mar 17, 2011 6:59 am   

Joined: Tue Mar 15, 2011 10:07 pm
Posts: 2
that works, thank you very much.


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP