Re: Fwd: Re: merging mono files

Kevin Conder <[email protected]>
Newsgroups gmane.comp.audio.sox
Message-ID <CALtij8gGBCpcjQUAahtKVHsC=E+eVy9ySi0kuSOE86QhQch7JQ@mail.gmail.com>
On Sun, Dec 11, 2016 at 12:43 AM, Erich Eckner <[email protected]> wrote:

> a quick search for "bash to windows shell converter" on google lead to:
>
> http://stackoverflow.com/questions/3200018/how-do-i-convert-a-bash-shell-script-to-a-bat-file
>
> wich seems to explain nearly all parts, you need to "translate" the bash
> scrip from Jan Stary into a .bat file.

Here's a quick VBScript file that I wrote instead. Make sure you
change the soxCommand variable to point to where your sox.exe file is
installed. Change all of the directory variables to your actual
directory locations before running it. Save the script as
"combine.vbs" and run it using "cscript combine.vbs".

    ' combine.vbs - Combine audio files from different directories.
    Option Explicit

    Dim exec
    Dim file
    Dim fileName
    Dim fso
    Dim leftDir
    Dim leftFolder
    Dim rightDir
    Dim shell
    Dim soxCommand
    Dim stereoDir
    Dim subFolder
    Dim subName

    ' Make sure these paths are correct before running.
    soxCommand = "C:\Program Files (x86)\sox-14-4-2\sox.exe"
    leftDir = "C:\Users\markb\Desktop\instruments\Basson16L\"
    rightDir = "C:\Users\markb\Desktop\instruments\Basson16R\"
    stereoDir = "C:\Users\markb\Desktop\instruments\Basson16S\"

    ' Use standard Windows objects.
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set shell = CreateObject("WScript.Shell")


    Sub CreateDir(name)
        ' Create a directory, if it does not exist.
        If Not fso.FolderExists(name) Then
            fso.CreateFolder(name)
        End If
    End Sub


    ' Create a directory for the combined stereo files.
    CreateDir(stereoDir)

    ' Loop through all of the subdirectories in the Left directory.
    Set leftFolder = fso.GetFolder(leftDir)
    For Each subFolder in leftFolder.SubFolders
        ' Create a corresponding subdirectory for the combined files.
        subName = subFolder.name
        CreateDir(stereoDir & subFolder.name)

        ' Loop through all of the the files in the subdirectory.
        For Each file in subFolder.Files
            ' Execute the sox command for each file.
            fileName = file.Name
            Set exec = shell.Exec(soxCommand & " -M " & _
                                   leftDir & subName & "\" & fileName & " " & _
                                   rightDir & subName & "\" & fileName & " " & _
                                   stereoDir & subName & "\" & fileName)

            WScript.Echo stereoDir & subName & "\" & fileName
        Next
    Next

    WScript.Echo "Done."

-- 
Kevin Conder

------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today.http://sdm.link/xeonphi
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.