R/file_naming.R

Defines functions skin_file

Documented in skin_file

#' @title
#' Remove Path and Extension of a File
#'
#' @param file String
#' @param rm_path Remove the path in the `file` argument?
#' @param rm_ext Remove the extension in the `file` argument?
#' @export


skin_file <-
  function(file,
           rm_path = TRUE,
           rm_ext = TRUE) {
    if (rm_path) {
      file <- basename(file)
    }

    if (rm_ext) {
      file <-
        sub(
          pattern = "(^.*)([.]{1}.*$)",
          replacement = "\\1",
          x = file
        )
    }

    file
  }
patelm9/cave documentation built on March 29, 2021, 6:28 p.m.