Last active
September 9, 2018 06:32
-
-
Save tushortz/a7afef63a3c6fcf4dd5589b040756a88 to your computer and use it in GitHub Desktop.
Powershell batch script to convert mpeg file to mp3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
############################## | |
# Author: Taiwo Kareem | |
# 09/09/2018 | |
# Script to convert between different audio file formats assuming ffmpeg exe is in Path environment variables | |
######################### | |
# HOW TO USE | |
# Create a new folder with the name of the old extension | |
# Place the new folder on your Desktop | |
# Change this next two lines for your preferred from and to format: | |
$AudioConvertionFormatFrom = 'mpeg'; | |
$AudioConvertionFormatTo = 'mp3'; | |
# That is all. Leave everything else below unchanged | |
# Your new files should be on the Desktop in the directory with the same name as 'AudioConvertionFormatTo' | |
$DesktopPath = [Environment]::GetFolderPath("Desktop"); | |
$AudioConvertionFormatFromPath = $DesktopPath + '\\' + $AudioConvertionFormatFrom; | |
$NewFolderPath = $AudioConvertionFormatFromPath.replace('\\'+$AudioConvertionFormatFrom, '\\'+$AudioConvertionFormatTo); | |
echo "Getting fonts from path: '$AudioConvertionFormatFromPath'"; | |
# Creating a new directory if not exist | |
if( -Not (Test-Path -Path $NewFolderPath ) ) | |
{ | |
New-Item -ItemType directory -Path $NewFolderPath | |
} | |
foreach($File in $(Get-ChildItem -Path $AudioConvertionFormatFromPath).Name){ | |
if ($File.EndsWith(".mpeg")){ | |
$NewFileName = $File.replace('.mpeg', '.mp3'); | |
$OldFilePath = $AudioConvertionFormatFromPath + "\\" + $File; | |
$NewFilePath = $NewFolderPath + "\\" + $NewFileName; | |
ffmpeg -i "$OldFilePath" -vn -ar 44100 -ac 2 -ab 192k -f mp3 "$NewFilePath"; | |
echo "$NewFileName conversion complete"; | |
} | |
} | |
echo "ALL CONVERSION COMPLETE"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment