Created
April 5, 2018 03:21
-
-
Save fauxneticien/df270bd1196f8e7a0d8c1a9e156428ce to your computer and use it in GitHub Desktop.
Rename files with regex in R
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(purrr) | |
library(stringr) | |
list.files("~/git-repos/coedl/dbd/public/pdfs", pattern = "PDFsam", full.names = TRUE) %>% | |
walk(function(path) { | |
file.rename( | |
path, | |
str_replace(path, "(\\d+)_PDFsam_(dbd-[A-Z]+).pdf", "\\2_\\1.pdf") | |
) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment