R/parent_base_ext.R

Defines functions parent_base_ext

Documented in parent_base_ext

#' Break a full file name to parent directory, name, and extension
#'
#' Option to get the file base name without extensions (e.g. .txt)
#' @author Al J Abadi, \email{aljalabadi@@gmail.com}
#' @title details of the file name
#' @param filePath Full name of the file
#' @importFrom tools file_ext
#' @return A list of file name details
#' @export
#' @keywords basename extension
#' @examples
#' \dontrun{parent_base_ext("directory/file.extension")}
#'
#' @family file

parent_base_ext <- function(filePath){

  file_dir <- dirname(filePath)
  file_name <- tools::file_path_sans_ext(basename(filePath))
  file_ext <- tools::file_ext(filePath)
  return(list(parent = file_dir, base = file_name, ext = file_ext))
}
aljabadi/Altools documentation built on Jan. 17, 2022, 8:55 a.m.