mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2025-01-16 01:40:35 -06:00
Code Formatting Changes - 'Copy-Files' Private Function
This commit is contained in:
parent
dbf3aa2d5c
commit
b7b64170d5
@ -18,30 +18,25 @@ function Copy-Files {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
$files = Get-ChildItem -Path $path -Recurse:$recurse
|
$files = Get-ChildItem -Path $path -Recurse:$recurse
|
||||||
Write-Host "Copy $($files.Count)(s) from $path to $destination"
|
Write-Host "Copy $($files.Count)(s) from $path to $destination"
|
||||||
|
|
||||||
foreach($file in $files)
|
foreach ($file in $files) {
|
||||||
{
|
|
||||||
$status = "Copy files {0} on {1}: {2}" -f $counter, $files.Count, $file.Name
|
$status = "Copy files {0} on {1}: {2}" -f $counter, $files.Count, $file.Name
|
||||||
Write-Progress -Activity "Copy Windows files" -Status $status -PercentComplete ($counter++/$files.count*100)
|
Write-Progress -Activity "Copy Windows files" -Status $status -PercentComplete ($counter++/$files.count*100)
|
||||||
$restpath = $file.FullName -Replace $path, ''
|
$restpath = $file.FullName -Replace $path, ''
|
||||||
|
|
||||||
if($file.PSIsContainer -eq $true)
|
if ($file.PSIsContainer -eq $true) {
|
||||||
{
|
|
||||||
Write-Debug "Creating $($destination + $restpath)"
|
Write-Debug "Creating $($destination + $restpath)"
|
||||||
New-Item ($destination+$restpath) -Force:$force -Type Directory -ErrorAction SilentlyContinue
|
New-Item ($destination+$restpath) -Force:$force -Type Directory -ErrorAction SilentlyContinue
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
Write-Debug "Copy from $($file.FullName) to $($destination+$restpath)"
|
Write-Debug "Copy from $($file.FullName) to $($destination+$restpath)"
|
||||||
Copy-Item $file.FullName ($destination+$restpath) -ErrorAction SilentlyContinue -Force:$force
|
Copy-Item $file.FullName ($destination+$restpath) -ErrorAction SilentlyContinue -Force:$force
|
||||||
Set-ItemProperty -Path ($destination+$restpath) -Name IsReadOnly -Value $false
|
Set-ItemProperty -Path ($destination+$restpath) -Name IsReadOnly -Value $false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Write-Progress -Activity "Copy Windows files" -Status "Ready" -Completed
|
Write-Progress -Activity "Copy Windows files" -Status "Ready" -Completed
|
||||||
}
|
} catch {
|
||||||
Catch{
|
|
||||||
Write-Warning "Unable to Copy all the files due to unhandled exception"
|
Write-Warning "Unable to Copy all the files due to unhandled exception"
|
||||||
Write-Warning $psitem.Exception.StackTrace
|
Write-Warning $psitem.Exception.StackTrace
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user