Honestly, you can do it in R if you want, but some tools are better than others for certain jobs. R just wouldn't be my first choice of tool to break up and rename a LOT of PDFs...
I wouldn't be able to help you with the regex for extracting the participant names without actually having access to the PDF, nor do I even know how possible it would be. But, breaking up a pdf into individual pages could be done by...
install.packages("pdftools")
library(pdftools)
#> Using poppler version 0.73.0
download.file("https://cran.r-project.org/doc/manuals/r-release/R-intro.pdf",
destfile = "r-intro.pdf", mode = "wb")
get_pages <- function(pdf, pages = seq_len(pdf_length(pdf))) {
get_one_page <- function(pdf, page) {
pdf_subset(pdf,
pages = page,
output = paste0(strsplit(pdf, "\\.")[[c(1, 1)]],
" ",
page,
".pdf"))
}
get_the_pages <- Vectorize(get_one_page,
vectorize.args = "page")
get_the_pages(pdf, pages)
}
pdf <- "r-intro.pdf"
get_pages(pdf)
Created on 2020-09-01 by the reprex package (v0.3.0)
Extracting the names will be a bit more difficult, especially to help with remotely, but once you can do that, renaming them will be easy.