Skip to content

Instantly share code, notes, and snippets.

@hl2guide
Created August 15, 2020 06:54
Show Gist options
  • Save hl2guide/55827c513bb8d6e2d040bd64fd45e5c1 to your computer and use it in GitHub Desktop.
Save hl2guide/55827c513bb8d6e2d040bd64fd45e5c1 to your computer and use it in GitHub Desktop.
A PowerShell script that downloads and upgrades ffmpeg Nightly for Windows
# Downloads and upgrades ffmpeg Nightly for Windows
# Saves time by changing a manual process to auto
# Start Edits
$destinationFolderTemp = "C:\Temp"
$finalDestinationFolder = "D:\Portable Software\Command Line Apps"
# End Edits
$uri = "https://ffmpeg.zeranoe.com/builds/win64/static/ffmpeg-latest-win64-static.zip"
$destinationFileTemp = "$destinationFolderTemp\ffmpeg-latest-win64-static.zip"
$destinationFolderFFMPEG = "$destinationFolderTemp\ffmpeg-latest-win64-static"
$fileToMove = "$destinationFolderTemp\ffmpeg-latest-win64-static\bin\ffmpeg.exe"
# Checks that the destination folder exists or not
if(!(Test-Path $destinationFolderTemp))
{
# Destination folder does not exist
Write-Host -ForegroundColor Red `
'ERROR: destination folder must exist'
exit
}
else
{
# Destination folder exists
Write-Host -ForegroundColor Green `
'INFO: Destination folder exists'
Write-Host -ForegroundColor Cyan `
'Downloading the latest FFMPEG Nightly, please wait..'
# Downloads the ZIP file
$wc = New-Object System.Net.WebClient
$wc.DownloadFile($uri, $destinationFileTemp)
}
# Extracts the ZIP to destination temp folder
Expand-Archive -LiteralPath $destinationFileTemp `
-DestinationPath $destinationFolderTemp -Force
# Moves the binary file (ffmpeg.exe)
Move-Item -Path $fileToMove `
-Destination $finalDestinationFolder -Force
# Removes the temp folder contents
Remove-Item -LiteralPath $destinationFolderFFMPEG `
-Recurse -Force
# Removes the temp ZIP file
Remove-Item -LiteralPath $destinationFileTemp `
-Force
Write-Host -ForegroundColor Green `
"Downloaded the latest FFMPEG Nightly to: $finalDestinationFolder"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment