Skip to content

Instantly share code, notes, and snippets.

@w0rp
Last active November 4, 2018 17:41
Show Gist options
  • Save w0rp/4be21e438479c8b54078098a22ae279e to your computer and use it in GitHub Desktop.
Save w0rp/4be21e438479c8b54078098a22ae279e to your computer and use it in GitHub Desktop.
A PowerShell script for downloading WoW addons easily
# This script downloads WoW addons to ~/Downloads in the new-addons directory,
# and replaces current versions of the addons with the updated addons.
# Makes Invoke-WebRequest not slow and useless.
$global:ProgressPreference = 'SilentlyContinue'
$ErrorActionPreference = "Stop"
cd ~/Downloads
$wowPath = "${env:ProgramFiles(x86)}\World of Warcraft\Interface\AddOns"
# Write (filename, url) here for the addons you want.
$downloadList = @(
,@("raider-io", "https://wow.curseforge.com/projects/raiderio/files/latest")
,@("dbm", "https://wow.curseforge.com/projects/deadly-boss-mods/files/latest")
,@("gathermate", "https://www.wowace.com/projects/gathermate2/files/latest")
,@("tomtom", "https://wow.curseforge.com/projects/tomtom/files/latest")
)
$exclusionList = @(
,"RaiderIO_DB_KR_A"
,"RaiderIO_DB_KR_H"
,"RaiderIO_DB_TW_A"
,"RaiderIO_DB_TW_H"
,"RaiderIO_DB_US_A"
,"RaiderIO_DB_US_H"
)
if (Test-Path "new-addons") {
Remove-Item -Force -Recurse "new-addons"
}
New-Item -ItemType directory -Path "new-addons" | Out-Null
Foreach ($download in $downloadList) {
$zip = "new-addons/$($download[0]).zip"
$dir = "new-addons/$($download[0])"
echo "Downloading: $($download[1])"
Invoke-WebRequest -Uri "$($download[1])" -OutFile "$zip"
echo "Extracting: $($zip)"
Expand-Archive "$zip" -DestinationPath "$dir"
Remove-Item "$zip"
}
Foreach ($download in $downloadList) {
Get-ChildItem "new-addons/$($download[0])" | Foreach-Object {
if ($exclusionList -contains $_.BaseName) {
continue
}
echo "Copying: $($_.BaseName)"
if (Test-Path "$wowPath/$($_.BaseName)") {
Remove-Item -Force -Recurse "$wowPath/$($_.BaseName)"
}
Copy-Item -recurse -literalPath "$($_.FullName)" `
-destination "$wowPath/$($_.BaseName)"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment