Skip to content

Instantly share code, notes, and snippets.

@jhauge
Created August 24, 2012 11:33
Show Gist options
  • Save jhauge/3449509 to your computer and use it in GitHub Desktop.
Save jhauge/3449509 to your computer and use it in GitHub Desktop.
A powershell script that puts all files from an Umbraco package in place and renames.
## Add this snippet to your profile script
## Profile script is usually found in
## c:\Users\yourname\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
## You can get the path by typing $PROFILE in a PS command prompt
##
## After adding the script to your profile, unpack the zip file in a directory
## Go to the dir in ps, and type "umbpack" then Enter (without quotes)
## Now you can find all the packages original files with their original (unpacked) names
## in the original folders
function global:Build-UmbracoPackage {
param($packageFile='.\package.xml')
[xml]$filesInXml = Get-Content $packageFile
$filesInXml.umbPackage.files.file | ForEach-Object {
[string]$guidName = $_.guid
[string]$newPath = $_.orgPath
[string]$newName = $_.orgName
$newPath = $newPath -Replace "/", "\"
Write-Host ".\$guidName -> .$newPath\$newName"
if (-not (Test-Path ".$newPath")) {
md ".$newPath"
}
Copy-Item -Path ".\$guidName" -Destination ".$newPath\$newName"
}
}
Set-Alias umbpack Build-UmbracoPackage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment