SHARE
TWEET

Duplicate File Structure With Empty Files

a guest Jul 14th, 2019 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $SourceRoot = "Z:\foo"
  2. $DestRoot = "Z:\bar"
  3. $SourceContent = Get-ChildItem $SourceRoot -Recurse
  4. $SourceContent | ForEach-Object {
  5.     If ($_.PSIsContainer) {$NewItemType = "Directory"}
  6.     Else {$NewItemType = "File"}
  7.    
  8.     $newitem = ($_.fullname).replace($SourceRoot, $DestRoot)
  9.     New-Item -Path $newitem -ItemType $NewItemType -force
  10.     (Get-Item -Path $newitem).LastWriteTime = $_.LastWriteTime
  11. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top