f_move_files: Move (or copy) files between folders

View source: R/f - Move files.R

f_move_filesR Documentation

Move (or copy) files between folders

Description

This function can be used to move (or copy) files from one folder (source) to another folder (destination).

Usage

f_move_files(
  c.path.source,
  c.path.destination,
  v.file.to.move = NULL,
  c.date.treshold = NULL,
  b.delete.from.source = TRUE,
  b.overwrite = TRUE,
  b.save.file.list = FALSE
)

Arguments

c.path.source

Full path to folder that holds files to be moved/copied.

c.path.destination

Full path to folder where files should be moved/copied to. In case it does not exist, it will be created. Though, the parent of the new folder must exist, else an error will be thrown.

v.file.to.move

List of files in c.path.source to be moved/copied. Each value should be the filename plus its extension. By default the value is NULL, resulting in the files to be moved/copied.

c.date.treshold

In case given - e.g., 'today() - 60' - files older than this date will be moved/copied. The date is derived from what is given in the filename. By default the value is NULL, resulting in the files to be moved/copied.

b.delete.from.source

Should we move or copy the files? By default the value is TRUE, effectively moving the files, and when set to FALSE, effectively copying the files.

b.overwrite

Should we overwrite files in case they are already present in the destination folder? By default the value is TRUE. In case, the value is set to FALSE, files will not be overwritten, if applicable.

b.save.file.list

Should we save the list of moved/copied files to an Excel file? The default is set to FALSE.

Details

In case files from the source folder already occur in the destination folder, they will not be removed from the source folder when b.overwrite has been set to FALSE and b.delete.from.source has been set to TRUE. This is to prevent loosing the concerned files.

Value

A data frame listing the moved/copied files.

Author(s)

Pieter Overdevest

Examples

df.move <- f_move_files(c.path.source = "...", c.path.destination = "...")

pieterov/generaltoolbox documentation built on Jan. 25, 2025, 10:32 a.m.