יום חמישי, 8 באוקטובר 2026


# Sync two Folders / Partitions with Robocopy.exe in Powershell prompt.

The following folders are for example only.

$Source = "$Env:UserProfile\Documents\Newfolder1"

$Destination = "$Env:UserProfile\Documents\Newfolder2"



# Sync two Folders / Partitions ( No Purge ):: List only

$Source = "$Env:UserProfile\Documents\Newfolder1"

$Destination = "$Env:UserProfile\Documents\Newfolder2"

$RoboCopy = "RoboCopy.exe"

$Switches = @( '/XO', '/E', '/R:0', '/W:0', '/MT', '/XA:SH', '/L' )

$RoboCopyArgs1 = @( $Source, $Destination ) + $Switches

$RoboCopyArgs2 = @( $Destination, $Source ) + $Switches

& $RoboCopy @RoboCopyArgs1

& $RoboCopy @RoboCopyArgs2

# Confirm

Write-Verbose "Would you like to Sync ? (Y/N)" -Verbose

$Choice = Read-Host

If ($Choice -in "Y","y" ) {

# Copy Sync two Folders / Partitions ( No Purge ) :: Copy Now

$Execute = $Switches | ? { $_ -ne '/L' }

$RoboCopyExecution1 = @( $Source, $Destination ) + $Execute

$RoboCopyExecution2 = @( $Destination, $Source ) + $Execute

& $RoboCopy @RoboCopyExecution1

& $RoboCopy @RoboCopyExecution2

} Else {

    Write-Warning "No Copy Execution Done. Aborting."

    Sleep -Seconds 3

    Return

}

#



 

אין תגובות:

הוסף רשומת תגובה

# Sync two Folders / Partitions with Robocopy.exe in Powershell prompt. The following folders are for example only. $Source = "$Env:Use...