openjusticeok / ojodb

OJO's R package for opening the black box of our justice system
https://openjusticeok.github.io/ojodb/
GNU General Public License v3.0
8 stars 3 forks source link

Add utility function to clean files names in given directory #73

Closed brancengregory closed 1 year ago

brancengregory commented 2 years ago

library(tidyverse)

clean_file_names <- function(dir) { if(!dir.exists(dir)) { stop("Directory does not exist") }

files <- list.files(dir, full.names = T)

new_files <- files |> str_to_lower() |> str_replaceall(" ", "")

lookups <- tibble( files, new_files ) |> rename( from = files, to = new_files )

lookups |> pwalk(file.rename) }

brancengregory commented 1 year ago

This should be implemented in ojoutils