function Copy-File-By_FileName { Param( [string] $sourceLocation, [string] $destinationClocation ) $files = gci -force $sourceLocation -recurse $files | foreach { $fileEnding = $_.FullName.Replace($sourceLocation, ""); $secondItem = $destinationClocation + $fileEnding ; if(Test-Path $secondItem) { write-host "File $secondItem exist"; } else { Write-Host "Creating empty file at location: $secondItem"; New-Item $secondItem -type file } } }
Przykład użycia kopiowania nazw plików:
$elapsed = [System.Diagnostics.Stopwatch]::StartNew() Copy-File-By_FileName -sourceLocation "C:\Files\" -destinationClocation "C:\EmptyFiles\" write-host "Time: $($elapsed.Elapsed.ToString())"
Brak komentarzy:
Prześlij komentarz