title: Rename files stored in a folder using a table
body: <p>I have a folder that contains a large amount of files from miscellaneous sources, mainly photos and videos. I have also a table in Excel with two columns: one with the original name of these files as stored in the folder, and another column with the new name to be renamed with.</p>
  
  <p>My question is: how can I rename the files stored in that folder using as a reference list the table in Excel?</p>
  
  <pre><code>library(tidyverse)
  
  # The original files of the photos are stored in a folder
  current.folder &lt;- "C:/Users/Tests/Desktop/Field_photos_2019"
  
  # Produce a table with mock-up names for the photos
  raw.table &lt;- tibble(IMG = rep(x = "IMG_", times = 10),
                      date.photo = rep(x = c("20190831", "20190901"), each = 5),
                      suffix = paste0(rep(x = "_", times = 10), sample(x = 1:100, size = 10), rep(x = ".jpg", times = 10)),
                      photo.title = paste0(IMG, date.photo, suffix))
  
  # Tidy up the table to make it look as the real table in Excel
  # Not sure if the mock-up names also need the file extension?
  mock.table &lt;- raw.table %&gt;%
                group_by(date.photo) %&gt;%
                mutate(no = 1:n()) %&gt;%
                ungroup() %&gt;%
                mutate(new.name = paste(date.photo, no, sep = "_")) %&gt;%
                select(photo.title, new.name)
  </code></pre>