Created
October 14, 2014 15:39
-
-
Save cjfarrelly/95a278a8d66a101a9019 to your computer and use it in GitHub Desktop.
The gist below will copy all html files from one directory to another keeping the directory structure in place
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
function Create-WebSite | |
{ | |
Push-Location ..\ | |
$webSiteContainer = "WebSite" | |
Remove-Item .\$webSiteContainer -Recurse -Force | |
New-Item -ItemType "directory" -Name $webSiteContainer | Out-Null | |
$items = Get-ChildItem -Recurse -Filter "*.html" | |
foreach ($item in $items) | |
{ | |
$itemRelativePath = $item | Resolve-Path -Relative | |
$itemRelativePath = $itemRelativePath.Remove(0,2) | |
$containingFolder = Join-Path $webSiteContainer $itemRelativePath.Replace($item.Name , "") | |
if(!(Test-Path $containingFolder)) | |
{ | |
New-Item -ItemType "directory" -Name $containingFolder | Out-Null | |
} | |
Move-Item -Path $item.FullName -Destination $containingFolder -Force | |
} | |
Pop-Location | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment