Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Вариант 10
- param (
- [int] $dir_from = "",
- [string] $dir_to = ""
- )
- #Write "Введите путь к директории 1:"
- #do {
- # $dir_from = Read-Host
- # $success = Test-Path $dir_from -PathType Container
- # if (!$success) {Write "Директория не найдена"}
- #} while(!$success)
- #Write "Введите путь к директории 2:"
- #do {
- # $dir_to = Read-Host
- # $success = Test-Path $dir_to -PathType Container
- # if (!$success) {Write "Директория не найдена"}
- #} while(!$success)
- Get-ChildItem $dir_from |
- ForEach-Object {
- if (Test-Path ($dir_to + "\" + $_.Name)){
- $same_name = Get-Item ($dir_to + "\" + $_.Name)
- if ($_.LastWriteTime -gt $same_name.LastWriteTime) {Copy-Item $_.FullName $dir_to}
- }
- else {Copy-Item $_.FullName $dir_to}
- }
Add Comment
Please, Sign In to add comment