Windows Vista Forums

Newbie alert!
  1. #1


    Axolotl Q Cleaver Guest

    Newbie alert!

    Although I've done much programming in the (distant) past I would
    appreciate five minutes of someone's time to help me get started with
    PowerShell.

    What I would like to do is pretty simple -
    Process each file in a directory using lame to produce a mp3 as follows
    lame -h -b 320 4RR_SYN69CD_track01.wav mp3\4RR_SYN69CD_track01.mp3

    I'm not sure whether to try to get all the filenames in the directory
    and process them to produce a complete script to run against the
    directory or whether to try to process the files one at a time - could I
    do this starting with Get-ChildItem?



    Or am I looking at the wrong tool for the job?

    TIA - Martin

      My System SpecsSystem Spec

  2. #2


    Andrew Savinykh Guest

    Re: Newbie alert!

    Assuming that you have lame.exe in the current directory and that you've
    already created the mp3 subfolder the following should work:

    gci *.wav | %{ $in = $_.Name; $out =
    [system.io.path]::ChangeExtension($in, "mp3"); ./lame -h -b 320 $in
    mp3/$out }

    //andrew


    Axolotl Q Cleaver wrote:
    > Although I've done much programming in the (distant) past I would
    > appreciate five minutes of someone's time to help me get started with
    > PowerShell.
    >
    > What I would like to do is pretty simple -
    > Process each file in a directory using lame to produce a mp3 as follows
    > lame -h -b 320 4RR_SYN69CD_track01.wav mp3\4RR_SYN69CD_track01.mp3
    >
    > I'm not sure whether to try to get all the filenames in the directory
    > and process them to produce a complete script to run against the
    > directory or whether to try to process the files one at a time - could I
    > do this starting with Get-ChildItem?
    >
    > Or am I looking at the wrong tool for the job?
    >
    > TIA - Martin


      My System SpecsSystem Spec

  3. #3


    Andrew Savinykh Guest

    Re: Newbie alert!

    This is slightly shorter:

    gci *.wav | %{ ./lame -h -b 320 $_.Name "mp3/$($_.Name -replace
    '\.wav$','.mp3')" }

    Andrew Savinykh wrote:
    > Assuming that you have lame.exe in the current directory and that you've
    > already created the mp3 subfolder the following should work:
    >
    > gci *.wav | %{ $in = $_.Name; $out =
    > [system.io.path]::ChangeExtension($in, "mp3"); ./lame -h -b 320 $in
    > mp3/$out }
    >
    > //andrew
    >
    >
    > Axolotl Q Cleaver wrote:
    >> Although I've done much programming in the (distant) past I would
    >> appreciate five minutes of someone's time to help me get started with
    >> PowerShell.
    >>
    >> What I would like to do is pretty simple -
    >> Process each file in a directory using lame to produce a mp3 as follows
    >> lame -h -b 320 4RR_SYN69CD_track01.wav mp3\4RR_SYN69CD_track01.mp3
    >>
    >> I'm not sure whether to try to get all the filenames in the directory
    >> and process them to produce a complete script to run against the
    >> directory or whether to try to process the files one at a time - could
    >> I do this starting with Get-ChildItem?
    >>
    >> Or am I looking at the wrong tool for the job?
    >>
    >> TIA - Martin


      My System SpecsSystem Spec

  4. #4


    Axolotl Q Cleaver Guest

    Re: Newbie alert!

    TVM for both working examples - now I just have to figure out how they
    work!!

    I've added this to the beginning of the script:
    if (!(Test-Path MP3 -PathType Container))
    {
    new-item -path . -name MP3 -type directory
    }

    The thing that remains to puzzle me is this:
    the path includes c:\windows\system32 which is where lame.exe and its
    associated .dll are kept - why does lame have to be in the current
    directory?

    Sorry to answer your helpful reply with another question!

    Best wishes - Martin

    Andrew Savinykh wrote:
    > This is slightly shorter:
    >
    > gci *.wav | %{ ./lame -h -b 320 $_.Name "mp3/$($_.Name -replace
    > '\.wav$','.mp3')" }
    >
    > Andrew Savinykh wrote:
    >> Assuming that you have lame.exe in the current directory and that
    >> you've already created the mp3 subfolder the following should work:
    >>
    >> gci *.wav | %{ $in = $_.Name; $out =
    >> [system.io.path]::ChangeExtension($in, "mp3"); ./lame -h -b 320 $in
    >> mp3/$out }
    >>


      My System SpecsSystem Spec

  5. #5


    Andrew Savinykh Guest

    Re: Newbie alert!

    Axolotl Q Cleaver wrote:
    > The thing that remains to puzzle me is this:
    > the path includes c:\windows\system32 which is where lame.exe and its
    > associated .dll are kept - why does lame have to be in the current
    > directory?

    It doesn't. I didn't know that you have in on the path, so I assumed
    it's in the current folder. If it is on the path, just change './lame'
    to 'lame' - should work.

      My System SpecsSystem Spec

Newbie alert! problems?

Similar Threads
Thread Thread Starter Forum Replies Last Post
Red Alert slk759 Live Mail 8 29 Mar 2010
Red Alert 3 Now Out. NormCameron Gaming 1 04 Nov 2008
Alert Help Alert Alert Help Alert this justin1 Gaming 2 07 Apr 2008
New Mail Alert Christopher Live Mail 2 14 Mar 2008
Alert Sounds =?Utf-8?B?Qm9i?= Vista General 0 18 Sep 2006