Results 1 to 6 of 6

Thread: Can someone help with a simple bash script?

  1. #1
    Join Date
    May 2007
    Location
    Philadelphia
    Beans
    Hidden!
    Distro
    Ubuntu 7.10 Gutsy Gibbon

    Can someone help with a simple bash script?

    I have some .ogg music files that I need converted to .mp3. I've used the command
    Code:
    for file in *.ogg;do oggdec -o - "$file"|lame -h -V 4 –-vbr-new - "$(basename "$file" .ogg).mp3";done
    before to convert every file in a folder, but I'd like to be able to just run the script and have it convert every .ogg in my Music folder. My Music folder is set up like Music>Artist>Album>Song.ogg. Can anyone help me out?

    Thank you

  2. #2
    Join Date
    Jan 2009
    Location
    MA
    Beans
    Hidden!
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: Can someone help with a simple bash script?

    I don't remember the exact syntax, but google for ...

    find dir -name *.ogg -exec ...
    The DRUNKS - For Your Inner Drunk

  3. #3
    Join Date
    Dec 2007
    Location
    Science Station Hermes
    Beans
    611
    Distro
    Ubuntu 9.04 Jaunty Jackalope

    Re: Can someone help with a simple bash script?

    You could try something like

    Code:
    find /path/to/music -name "*.ogg" | while read file
    'file' would remain your variable. I think this should work.
    Quote Originally Posted by Legendary_Bibo View Post
    I tried, and by tried I mean I did a half a**ed google search, and by half a**ed google search I mean I typed "eread pdg"

  4. #4
    Join Date
    Nov 2006
    Location
    Belgium
    Beans
    3,025
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Can someone help with a simple bash script?


  5. #5
    Join Date
    Nov 2009
    Location
    /dev/null
    Beans
    74

    Re: Can someone help with a simple bash script?

    Not sure I understand corretly, but are you saying that you have multiple directories separated for each artists or such and you want to covert all of them at one shot ?

    Between pushd and popd, you are already in the OGG directory. Replace 'echo $x $y $z' with whatever command(s) you want to run.

    Code:
    #!/bin/csh
     
    foreach file (`find <top music dir> -name "*ogg" -print`)
       set dir=$file:h
       pushd $dir
         echo "changing dir to $dir.."
         set x = $file:t
         set y = $file:r:t
         set z = $y."mp3"
         echo "$x  $y $z"
       popd
    end
    Last edited by lostinxlation; June 7th, 2010 at 09:27 PM.

  6. #6
    Join Date
    May 2007
    Location
    Philadelphia
    Beans
    Hidden!
    Distro
    Ubuntu 7.10 Gutsy Gibbon

    Re: Can someone help with a simple bash script?

    Thank you all, but I found the program ogg2mp3 which has worked wonderfully.

    Thanks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •