Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Add-Type -AssemblyName System.Windows.Forms # Only need this once
- Function get-files{
- $FileBrowser = New-Object System.Windows.Forms.OpenFileDialog -Property @{
- InitialDirectory = '\\networkshare\someshare'
- Filter = 'zip (*.zip)|*.zip'
- Multiselect = $true
- }
- [void]$FileBrowser.ShowDialog()
- $FileBrowser.FileNames
- }
- Function Move-files {
- $FolderBrowser = New-Object System.Windows.Forms.FolderBrowserDialog -Property @{
- SelectedPath = 'D:\TMP'
- }
- [void]$FolderBrowser.ShowDialog()
- $FolderBrowser.SelectedPath
- }
- # Define Vars upfront
- $openfile = get-files
- $movefile = Move-files
- $tempFldr = "D:\TMP"
- # Make sure the TMP folder exists first
- IF (!(Test-Path D:\TMP)) { New-Item -Path D: -Name TMP -Type Directory | Out-Null}
- # Multiselect is true above, so if there are multiple zips, this will handle each, one at a time
- Foreach ($file in $openfile) {
- $folder = ($file.Split(".")).split("\")[1]
- Expand-Archive -Path $file -DestinationPath $tempFldr -Force
- New-Item -Path $movefile -Name $folder -ItemType Directory | Out-Null
- Copy-Item $tempFldr\*.* -Exclude *.zip -Destination $movefile\$folder
- Remove-Item E:\TMP -Recurse
- }
Advertisement
Add Comment
Please, Sign In to add comment