Created
May 16, 2019 22:14
-
-
Save dwhdai/04df75a83b6fa0a0b5f34c6d5aac787e to your computer and use it in GitHub Desktop.
This script can be used to automate moving/archiving files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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