Skip to contents

Partially synchronize right directory based on left one -i.e., the function will:

  • for common_files:

    • if by date only: copy files that are newer in left to right

    • if by date and content: copy files that are newer and different in left to right

    • if by content only: copy files that are different in left to right

  • for non common files, nothing changes: i.e.,

    • disregard those files that are only in left

    • keep in right those files that are only in right (i.e., files 'missing in left')

Usage

common_files_asym_sync_to_right(
  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

# Compare directories with 'compare_directories()'
e <- toy_dirs()
#> ■■■■■■■■■■■■■■■                   47% | ETA:  5s
#> ■■■■■■■■■■■■■■■■■■■■■■■■■■■       87% | ETA:  1s

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

# Example: Synchronize by content only
# Option 1
common_files_asym_sync_to_right(left_path  = left,
                                right_path = right,
                                by_date    = FALSE,
                                by_content = TRUE)
#> ✔ synchronized
#>