#' Removes all accent of all files in the choosen folder.
#'
#' @dir Character. Folder where are the files. The user must write the path of the folder (there is no default).
#' @sub_folder Logical. If files within nested folders should be used.
#' @keywords acentos
#' @export
#' @examples
#' do not run!
#' my_folder <- getwd()
#' remove_acento_arquivos(my_folder)
remove_acento_arquivos <- function(dir, sub_folder=T) {
# if(!require(stringi)) {
# install.packages("stringi")
# stopifnot(require(stringi))
# }
setwd(dir)
vec_from <- list.files(pattern = "[áàãâéêíóôõúüçÁÀÂÃÉÊÍÓÔÕÚÜÇ]", recursive = sub_folder)
vec_to <- stringi::stri_trans_general(vec_from, "latin-ascii")
file.rename(vec_from, vec_to)
x <- length(vec_from)
print(paste0("Foram renomeados ", x , " arquivos no total"))
if(x > 0) {
resposta <- tolower(recebe_input())
if (resposta == "s") {
print(vec_to)
} else {
if(resposta == "n") {
"você respondeu não. Programa encerrado"
} else {
print("você não respondeu nem 's' nem 'n'")
}
}
}
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.