Skip to contents

update non common files in right directory based on left one -i.e., the function will:

  • for common_files:

    • do nothing, left unchanged

  • for non common files,

    • copy those files that are only in left to right

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

Usage

update_missing_files_asym_to_right(
  left_path = NULL,
  right_path = NULL,
  sync_status = NULL,
  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().

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()
#> ■■■■■■■                           20% | ETA:  8s
#> ■■■■■■■■■■■■■■■■■                 53% | ETA:  6s

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

# Option 1
update_missing_files_asym_to_right(left_path  = left,
                                   right_path = right)
#> ✔ synchronized
#> 
# Option 2
sync_status = compare_directories(left,
                                  right)

update_missing_files_asym_to_right(sync_status = sync_status)
#> ✔ synchronized
#>