Learn R Programming

syncdr (version 0.1.1)

compare_directories: Compare Two Directories for Synchronization Status

Description

This function compares two directories, typically referred to as 'left' and 'right', to determine their synchronization status at the file level. The primary goal is to identify the synchronization status of files present in both directories and those exclusive to either directory.

Usage

compare_directories(
  left_path,
  right_path,
  recurse = TRUE,
  by_date = TRUE,
  by_content = FALSE,
  verbose = getOption("syncdr.verbose")
)

Value

A list of class "syncdr_status" containing the following elements:

  • Non-common files: Paths and synchronization status of files exclusive to either directory.

  • Common files: Paths and synchronization status of files present in both directories.

  • Path of the left directory.

  • Path of the right directory.

Arguments

left_path

Path to the left/first directory.

right_path

Path to the right/second directory.

recurse

If TRUE, fully recurses through subdirectories. If a positive integer, specifies the number of levels to recurse.

by_date

Logical. If TRUE (default), compares directories based on the modification date of common files.

by_content

Logical. If TRUE, compares directories based on the hashed content of common files. Default is FALSE

verbose

Logical. If TRUE display additional info on the comparison process. Default is FALSE

Sync Status Types

The synchronization status is determined for files present in both directories, as well as for files exclusive to either directory. It can be computed based on modification date only, content only, or both.

For Common Files:

  • When comparing by date: 'new', 'old', or 'same'.

  • When comparing by date and content: 'new and different', 'new and same', 'old and different', 'old and same', 'same and different', or 'same and same'.

  • When comparing by content only: 'different' or 'same'.

For Non-Common Files:

  • When comparing by date (or by date and content, or by content only): 'only in left' or 'only in right'.

Examples

Run this code
# \donttest{
e <- toy_dirs()
left  <- e$left
right <- e$right
compare_directories(left, right)
compare_directories(left, right, by_content = TRUE)
compare_directories(left, right, by_content = TRUE, by_date = FALSE)
# }

Run the code above in your browser using DataLab