Created
July 15, 2022 17:07
-
-
Save dmtrek14/9992f6f91cf5910867a05465c9ab279f to your computer and use it in GitHub Desktop.
Powershell script to make a copy of just the structure of a folder
This file contains 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
param | |
( | |
[parameter(Mandatory = $true)] | |
[String] $ExistingFolderName, | |
[parameter(Mandatory = $true)] | |
[String] $CopiedFolderName | |
) | |
function Create-FolderStructureCopy { | |
[CmdletBinding()] | |
param | |
( | |
[parameter(Mandatory = $true)] | |
[string] $ExistingFolderName , | |
[parameter(Mandatory = $true)] | |
[String] $CopiedFolderName | |
) | |
process { | |
#module for notifications | |
Install-Module -Name BurntToast -SkipPublisherCheck -Force | |
$copiedFolderDestination = "{path to copied folder}" | |
## copied folder destination | |
Set-Location $copiedFolderDestination | |
if (!(Test-Path $CopiedFolderName)) { | |
Write-Host "Starting copy of exisiting folder structure ..." | |
robocopy $ExistingFolderName $CopiedFolderName /e /xf * | |
New-BurntToastNotification -Text "$CopiedFolderName Folder Structure Created", 'Empty folder structure has been created.' | |
} | |
else { | |
Write-Host "Folder for $CopiedFolderName already exists" | |
} | |
} | |
} | |
Create-FolderStructureCopy -ExistingFolderName $ExistingFolderName -CopiedFolderName $CopiedFolderName |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment