Skip to content

Instantly share code, notes, and snippets.

@sbalci
Forked from summerofgeorge/rename-jpg-files.r
Created October 29, 2019 10:08
Show Gist options
  • Save sbalci/2894168c45c36aa897e9db0831c62b7d to your computer and use it in GitHub Desktop.
Save sbalci/2894168c45c36aa897e9db0831c62b7d to your computer and use it in GitHub Desktop.
Rename all jpg files in a folder
# List the jpg files in the folder
old_files <- list.files("C:/ImageTest", pattern = "*.JPG", full.names = TRUE)
old_files
# Create vector of new files
new_files <- paste0("C:/NewFiles/file_",1:length(old_files),".JPG")
new_files
# Copy from old files to new files
file.copy(from = old_files, to = new_files)
# Clear out the old files
#file.remove(old_files)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment