LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-21-2010, 02:54 AM   #1
cicca82
LQ Newbie
 
Registered: Oct 2007
Posts: 13

Rep: Reputation: 0
Convert wma with a script


I have some wma file which I would like to convert to mp3. My situation is that the wma files are in different sub directories. I already have a good script which I found online but its problem is that you only can convert wma in current directory. I would like to edit this script, so I can be able to convert my wma files in sub directories too.

A copy of script is below:

Code:
#!/bin/bash

# Dump wma to mp3
# from http://ocaoimh.ie/2005/08/16/how-to-convert-from-wma-to-mp3/

for src in *.wma
do
  if [ -f "$src" ]
  then
    fifo=`echo "$src"|sed -e 's/wma$/wav/'`
    rm -f "$fifo"
    mkfifo "$fifo"
    mplayer -vo null -vc dummy -af resample=44100 -ao pcm:waveheader \
"$src" -ao pcm:file="$fifo" &
    dest=`echo "$src"|sed -e 's/wma$/mp3/'`
    lame --vbr-new "$fifo" "$dest"
    rm -f "$fifo"
  fi
done
I don't have that much experience in scripting but I think that don't need that much modifications to meet my requirements.

Thanks for help me out.
cicca
 
Old 07-21-2010, 03:33 PM   #2
jv2112
Member
 
Registered: Jan 2009
Location: New England
Distribution: Arch Linux
Posts: 719

Rep: Reputation: 103Reputation: 103
Install Sound Converter

Easy to use and no need to mess with a script you are unsure off.
 
1 members found this post helpful.
Old 07-21-2010, 03:45 PM   #3
timsgreen
LQ Newbie
 
Registered: Mar 2006
Posts: 14

Rep: Reputation: 2
If you want to continue to use your script, give the 'find' utility a try:

Code:
$DIR='/my/media/dirs'
for src in $(find $DIR -type f -name "*.wma")
do
# Your code here.  Note that the find command eliminates the need to check if it is type file, so the if statement is redundant.
done
 
1 members found this post helpful.
Old 07-26-2010, 10:17 AM   #4
cicca82
LQ Newbie
 
Registered: Oct 2007
Posts: 13

Original Poster
Rep: Reputation: 0
Thanks both of you for your reply. I will try both methods and I will let you know which is most useful tool I found.

Thanks once again

cicca82
 
Old 07-26-2010, 10:28 AM   #5
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,424

Rep: Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823
Be cautious of the for loop if your files have spaces in them. If they do I would recommend a while loop instead.
 
Old 07-26-2010, 10:47 AM   #6
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,697
Blog Entries: 5

Rep: Reputation: 244Reputation: 244Reputation: 244
Code:
#!/bin/bash
shopt -s nullglob
shopt -s nocaseglob
find /path -iname "*.wma" | while read -r src
do
    fifo="${src%wma}wav"
    rm -f "$fifo"
    mkfifo "$fifo"
    mplayer -vo null -vc dummy -af resample=44100 -ao pcm:waveheader "$src" -ao pcm:file="$fifo" &
    dest="${src%wma}mp3"
    lame --vbr-new "$fifo" "$dest"
    rm -f "$fifo"
done
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert wma to ogg lixy Linux - Software 20 10-12-2011 06:58 PM
DISCUSSION: Convert WMA to MP3 cadj LinuxAnswers Discussion 101 06-05-2011 10:06 AM
convert wma > mp3? andrewlkho Linux - Software 31 08-20-2007 01:26 AM
Application to Convert WMA to MP3? edwin11 Linux - Software 2 02-02-2006 10:25 AM
how to convert a wma to mp3?? yenonn Linux - General 2 04-26-2004 08:25 PM


All times are GMT -5. The time now is 01:10 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration