Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
function Select-Folder($message='Select a folder', $path = 0) {
$object = New-Object -comObject Shell.Application
$folder = $object.BrowseForFolder(0, $message, 0, $path)
if ($folder -ne $null) {
function Add-Zip
if(-not (test-path($zipfilename)))
set-content $zipfilename ("PK" + [char]5 + [char]6 + ("$([char]0)" * 18))
(dir $zipfilename).IsReadOnly = $false
$shellApplication = new-object -com shell.application
$zipPackage = $shellApplication.NameSpace($zipfilename)
foreach($file in $input)
Start-sleep -milliseconds 500
$folder = Select-Folder 'Select the SketchFlow Package Folder...'
#could prompt user for deployment location also, for the final compressed file
$deploymentFolder = "$folder\..\Deployment"
$types = ".xap", ".html"
#PSisContainer - fetches only files not directories
#Group-Object - assists in the ForEach loop that performs the copy
$files= Get-ChildItem $folder | Where-Object {-not$_.PSisContainer} | Group-Object Extension
$files = $files | Where-Object {$types-contains$_.Name}
New-Item -itemType Directory -path $deploymentFolder -ea SilentlyContinue
$files | ForEach-Object { $_.Group | Copy-Item -destination $deploymentFolder }
#rename testpage to something even more obvious
Move-Item "$deploymentFolder\TestPage.html" "$deploymentFolder\LaunchMe.html"
Get-ChildItem $deploymentFolder -Recurse | Add-Zip "$folder\"
#moving the file because Add-Zip cannot take an adjusted path ($folder\..\ as input.
Move-Item "$folder\" "$folder\..\"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment