Skip to content

Instantly share code, notes, and snippets.

@dwhdai
Created May 16, 2019 22:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dwhdai/04df75a83b6fa0a0b5f34c6d5aac787e to your computer and use it in GitHub Desktop.
Save dwhdai/04df75a83b6fa0a0b5f34c6d5aac787e to your computer and use it in GitHub Desktop.
This script can be used to automate moving/archiving files
# List all files in directory which contains the file to be archived
files <- list.files("/path/to/file/")
# A distinguishing substring that allows you to identify the file to be archived
substring <- "some_substring"
# Select the file based on distinguishing substring
old_file <- files[which(stringr::str_detect(files, substring))]
# Move report to archive folder
file.rename(from = paste0("/path/to/file/", old_file),
to = paste0("/path/to/archive/folder/", old_report))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment