Skip to content

Instantly share code, notes, and snippets.

@njtierney
Created September 4, 2020 04:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save njtierney/0e4580ca276fe018f4e1d7bc6e52e5fb to your computer and use it in GitHub Desktop.
Save njtierney/0e4580ca276fe018f4e1d7bc6e52e5fb to your computer and use it in GitHub Desktop.
chapters <- list.files(pattern = "^[0-9]")
new_chapters <- stringr::str_remove_all(chapters, "[0-9][0-9]-")
file.rename(from = chapters[1],
to = new_chapters[1])
chapters <- list.files(pattern = "^[0-9]")
new_chapters <- stringr::str_remove_all(chapters, "[0-9][0-9]-")
purrr::walk2(.x = chapters,
.y = new_chapters,
.f = file.rename)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment