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?

2
  • &"xxx\sox-14-4-2\sox.exe" "-t" "raw" "-r" "8000" "-e" "a-law" "$way.vox" "$way.mp3" Commented Jan 29, 2018 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. Commented Jan 29, 2018 at 15:50

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

2 Comments

Don't think the $() in a-law $() $inputFile $outputFile is actually required?
Well spotted @JamesC. - that was a remnant from a quick refactor for clarity!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.