transmit: Transmit files from a remote FTP server

View source: R/transmit.R

transmitR Documentation

Transmit files from a remote FTP server

Description

Utility function that supports easy file matching and download from a remote FTP server. Also enables on-the-fly file renaming and compression.

Usage

transmit(
  remoteDir,
  localDir = getwd(),
  pattern = NULL,
  rename = NULL,
  compress = FALSE,
  download = TRUE
)

Arguments

remoteDir

character(1). Remote FTP directory path.

localDir

character(1). Directory where to save files locally.

pattern

character(1). Pattern to use for matching.

rename

character(1) or NULL. Rename the local files (including suffix), if desired.

compress

logical(1). Compress the downloaded files.

download

logical(1). Download files (default) or only return the matching URL(s).

Value

Invisible character. Local file paths.

Note

Updated 2023-09-19.

Examples

remoteDir <- "ftp://ftp.ncbi.nlm.nih.gov/genomes/"
if (goalie::isAnExistingUrl(remoteDir)) {
    localDir <- AcidBase::tempdir2()
    readme <- transmit(
        remoteDir = remoteDir,
        localDir = localDir,
        pattern = "^README\\.txt$",
        rename = "ncbi-readme.txt",
        compress = FALSE
    )
    basename(readme)
    file.exists(readme)
    AcidBase::unlink2(localDir)
}

acidgenomics/pipette documentation built on Jan. 31, 2024, 10:32 p.m.