0

I have a zip file, with lots of directories and files. Somewhere are .vox files.

I have script in PowerShell that unzips and finds all .vox files.

Than I have command line program sox, which can convert vox file to mp3. But it works only in cmd.

sox -t raw -r 8000 -e a-law inputfile outputfile

Is possible run this command under PS with inputfile and outputfile variables, so I can use sox with a lot of vox files? Maybe foreach?

henrycarteruk
  • 12,708
  • 2
  • 36
  • 40
  • &"xxx\sox-14-4-2\sox.exe" "-t" "raw" "-r" "8000" "-e" "a-law" "$way.vox" "$way.mp3" – Jean Gaunt Jan 29 '18 at 15:46
  • If you've got a script already, it's best to include its code so we can see what you're doing. If you edit your question to include this you'll get a more relevant answer. – henrycarteruk Jan 29 '18 at 15:50

1 Answers1

0

Something like this should work

$sourceDirectory = "C:\voxfiles"
$destinationDirectory = "C:\soxfiles"

# Grab the list of files
$voxFiles = Get-ChildItem -Path $sourceDirectory -Filter "*.vox"

# Loop over the files
foreach ($voxFile in $voxFiles) {
    $inputFile = $voxFile.FullName
    $outputFile = Join-Path -Path $destinationDirectory -ChildPath $voxFile.Name

    # Call CMD
    & "Sox -t raw -r 8000 -e a-law $inputFile $outputFile"
}

Running CMD command in Powershell

gvee
  • 16,732
  • 35
  • 50