R/check_uppercase.R

Defines functions upper_extension convert_extension

convert_extension <- function(ext){
  pattern <- paste0(ext, '$')
  from <- list.files(pattern = pattern, recursive = TRUE)
  to <- sub(pattern, tolower(ext), from)
  file.rename(from, to)
}

upper_extension <- function(ext){
  pattern <- paste0(ext, '$')
  from <- list.files(pattern = pattern, recursive = TRUE)
  if (!identical(from, character(0))){
    stop(
      sprintf("Les fichiers suivants ont une majuscule:\n %s",
              paste(from, collapse = ";\n  "))
    )
  } else{
    message("Pas de probleme d'extension")
  }
}
InseeFrLab/utilitr-template documentation built on Oct. 21, 2022, 11:42 p.m.