Created
November 20, 2010 20:30
-
-
Save gatesvp/708126 to your computer and use it in GitHub Desktop.
Copy all files for a given MediaShout presentation (along with the presentation) into a single folder. Update the presentation to use the locally referenced files, this way the presentation is actually self-contained.
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
| # Select-FileDialog Function # | |
| # Created by Hugo Peeters # | |
| # http://www.peetersonline.nl # | |
| ############################### | |
| # Note: store in your profile for easy use | |
| # Example use: | |
| # $file = Select-FileDialog -Title "Select a file" -Directory "D:\scripts" -Filter "Powershell Scripts|(*.ps1)" | |
| function Select-FileDialog | |
| { | |
| param([string]$Title,[string]$Directory,[string]$Filter="All Files (*.*)|*.*") | |
| [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") | Out-Null | |
| $objForm = New-Object System.Windows.Forms.OpenFileDialog | |
| $objForm.InitialDirectory = $Directory | |
| $objForm.Filter = $Filter | |
| $objForm.Title = $Title | |
| $Show = $objForm.ShowDialog() | |
| If ($Show -eq "OK") | |
| { | |
| Return $objForm.FileName | |
| } | |
| Else | |
| { | |
| Write-Error "Operation cancelled by user." | |
| } | |
| } | |
| function New-Zip | |
| { | |
| param([string]$zipfilename) | |
| set-content $zipfilename ("PK" + [char]5 + [char]6 + ("$([char]0)" * 18)) | |
| (dir $zipfilename).IsReadOnly = $false | |
| } | |
| function Add-Zip | |
| { | |
| param([string]$zipfilename) | |
| 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) | |
| { | |
| $zipPackage.CopyHere($file.FullName) | |
| Start-sleep -milliseconds 500 | |
| } | |
| } | |
| ######## | |
| # File selector | |
| ######## | |
| $file_path = Select-FileDialog -Title "Select a MediaShout file" -Directory "C:\Documents and Settings\David Kelch\My Documents\WORSHIP\MediaShout Presentations\" | |
| $file = (ls $file_path); | |
| ######## | |
| # Generate a clean temp folder | |
| ######## | |
| $export_folder = "$env:temp\"+$file.BaseName; | |
| if(-not (Test-Path $export_folder) ) { mkdir $export_folder | out-null; } | |
| rm "$export_folder\*" -Force | |
| ######## | |
| # Copy ssc file to temp | |
| ######## | |
| "Copying Mediashout file" | |
| cp $file_path $export_folder | |
| $backup_name = ls ($export_folder+"\*.ssc") | select -first 1 | |
| ######## | |
| # Load *.ssc as XML file | |
| # Copy files to temp folder with new names | |
| # Update *.ssc to point at those files. | |
| ######## | |
| "Copying images" | |
| [xml]$list = cat $backup_name | |
| $slides = $list.MediaShout_Document | gm -MemberType property | % { if($_.Name -match 'CueN') { $_.Name } } ; | |
| $slides | % { if(($list.MediaShout_Document.$_.Background.Path) -and ($list.MediaShout_Document.$_.Background.Path -ne '') ) { $old_path = $list.MediaShout_Document.$_.Background.Path.Replace('&','&'); if($old_path -ne '') { $old_file = (ls $old_path); $new_name = ($_).Replace("CueN",'slide')+$old_file.extension; $new_path = $export_folder+"\"+$new_name; cp $old_path $new_path; $list.MediaShout_Document.$_.Background.Path = $new_name} } } | |
| $list.Save(($backup_name.FullName)) | |
| ######## | |
| # Zip files to original folder for backup | |
| ######## | |
| "Zipping files" | |
| $zip_path = $file.DirectoryName+"\"+$file.BaseName+".zip" | |
| new-zip $zip_path | |
| ls $export_folder | add-zip $zip_path | |
| ######## | |
| # Remove temp on successful zip | |
| ######## | |
| "Cleaning up" | |
| rm "$export_folder" -Force -Recurse | |
| ######## | |
| # Open original folder to highlight file | |
| ######## | |
| $ShellExp = new-object -comObject Shell.Application | |
| $ShellExp.open($zip_path) |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Newest version also provides a pop-up for selecting files along with a zip. So the files are all copied and modified in a temp folder and then zipped back into the original folder. The temp files are then deleted and you have a nice little backup package.