Skip to content

Instantly share code, notes, and snippets.

@sbalci
Created September 5, 2021 15:38
Show Gist options
  • Save sbalci/d1ec08be18d6a021772a6ff7cad19ef7 to your computer and use it in GitHub Desktop.
Save sbalci/d1ec08be18d6a021772a6ff7cad19ef7 to your computer and use it in GitHub Desktop.
# batch rename files
Book1 <- read.csv(file.choose())
wd <- dirname(file.path(file.choose()))
for (i in 1:dim(Book1)[1]) {
oldfilepath <- paste0(wd, "/", Book1[i,2])
newfilepath <- paste0(wd, "/",Book1[i,1],".txt")
file.rename(from = oldfilepath, to = newfilepath)
}
# https://git.io/JuqOE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment