Skip to contents

This function updates directories in the following way:

  • For common files:

    • if by date: If the file in one directory is newer than the corresponding file in the other directory, it will be copied over to update the older version. If modification dates are the same, nothing is done

    • if by date and content: If the file in one directory is newer AND different than the corresponding file in the other directory, it will be copied over to update the older version. If modification dates/contents are the same, nothing is done

    • if by content only: this option is not active

  • For non common files: unchanged, i.e.,

    • keep in right those that are only in right

    • keep in left those that are only in left

Usage

partial_symmetric_sync_common_files(
  left_path = NULL,
  right_path = NULL,
  sync_status = NULL,
  by_date = TRUE,
  by_content = FALSE,
  recurse = TRUE,
  force = TRUE,
  backup = FALSE,
  backup_dir = "temp_dir",
  verbose = getOption("syncdr.verbose")
)

Arguments

left_path

Path to the left/first directory.

right_path

Path to the right/second directory.

sync_status

Object of class "syncdr_status", output of compare_directories().

by_date

logical, TRUE by default

by_content

logical, FALSE by default

recurse

logical, TRUE by default. If recurse is TRUE: when copying a file from source folder to destination folder, the file will be copied into the corresponding (sub)directory. If the sub(directory) where the file is located does not exist in destination folder (or you are not sure), set recurse to FALSE, and the file will be copied at the top level

force

Logical. If TRUE (by default), directly perform synchronization of the directories. If FALSE, displays a preview of actions and prompts the user for confirmation before proceeding. Synchronization is aborted if the user does not agree.

backup

Logical. If TRUE, creates a backup of the right directory before synchronization. The backup is stored in the location specified by backup_dir.

backup_dir

Path to the directory where the backup of the original right directory will be stored. If not specified, the backup is stored in temporary directory (tempdir).

verbose

logical. If TRUE, display directory tree before and after synchronization. Default is FALSE

Value

Invisible TRUE indicating successful synchronization.

Examples

# Create syncdr environment with toy directories
e <- toy_dirs()
#> ■■■■■■■                           20% | ETA:  8s
#> ■■■■■■■■■■■■■■■■■                 53% | ETA:  6s

# Get left and right directories' paths
left  <- e$left
right <- e$right

# Synchronize directories, e.g., by date
# Option 1 - providing left and right paths
full_symmetric_sync(left_path  = left,
                    right_path = right,
                    by_date    = TRUE)
#> ✔ synchronized
#> 
# Option 2 - Providing sync_status object
sync_status = compare_directories(left_path  = left,
                                  right_path = right)
full_symmetric_sync(sync_status = sync_status)
#> ✔ synchronized
#>