Created
October 2, 2020 15:24
-
-
Save halityurttas/686e56febe38f148fe7e37fee5705767 to your computer and use it in GitHub Desktop.
Copy diff files to target with folder hierarchy from a text file
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
$des = "d:\diff_backup\" | |
$safe = Get-Content ".\diff.txt" | |
$safe | ForEach-Object{ | |
#find drive-delimeter | |
$first=$_.IndexOf(":\"); | |
if($first -eq 1){ | |
#stripe it | |
$newdes=Join-Path -Path $des -ChildPath @($_.Substring(0,1)+$_.Substring(2))[0] | |
} | |
else{ | |
$newdes=Join-Path -Path $des -ChildPath $_ | |
} | |
$folder=Split-Path -Path $newdes -Parent | |
$err=0 | |
#check if folder exists" | |
$void=Get-Item $folder -ErrorVariable err -ErrorAction SilentlyContinue | |
if($err.Count -ne 0){ | |
#create when it doesn't | |
$void=New-Item -Path $folder -ItemType Directory -Force -Verbose | |
} | |
$void=Copy-Item -Path $_ -destination $newdes -Recurse -Container -Force -Verbose | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Generate diff.txt for
$ git diff --name-status firstbranchorcommit yourbranchorcommit > diff.txt