Ilitid

Лаба 1

Dec 13th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Вариант 10
  2.  
  3. param (
  4.     [int] $dir_from = "",
  5.     [string] $dir_to = ""
  6. )
  7.  
  8. #Write "Введите путь к директории 1:"
  9. #do {
  10. #    $dir_from = Read-Host
  11. #    $success = Test-Path $dir_from -PathType Container
  12. #    if (!$success) {Write "Директория не найдена"}
  13. #} while(!$success)
  14.  
  15. #Write "Введите путь к директории 2:"
  16. #do {
  17. #    $dir_to = Read-Host
  18. #    $success = Test-Path $dir_to -PathType Container
  19. #    if (!$success) {Write "Директория не найдена"}
  20. #} while(!$success)
  21.  
  22. Get-ChildItem $dir_from |
  23. ForEach-Object {
  24.     if (Test-Path ($dir_to + "\" + $_.Name)){
  25.         $same_name = Get-Item ($dir_to + "\" + $_.Name)
  26.         if ($_.LastWriteTime -gt $same_name.LastWriteTime) {Copy-Item $_.FullName $dir_to}
  27.     }
  28.     else {Copy-Item $_.FullName $dir_to}
  29. }
Add Comment
Please, Sign In to add comment