Quick summary:
This R script automates file or folder copying — handy when you regularly pull updated data or resources from another project.
Instead of manually dragging files around, just run this script and it’ll take care of the copying for you.
💡 Rule of thumb: If you’ve copied the same file or folder three or more times, it’s officially time to automate it.
How to use:
-
Open the script and set the two paths:
# Source (the file or folder you want to copy) source_file_path <- "PATH_TO_FILE(S)_OR_FOLDER(S)_TO_COPY" # Destination (the folder where you want to place the copy) destination_folder_path <- "PATH_TO_FOLDER_TO_BE_COPIED_INTO"
⚠️ Use forward slashes (/) in paths — even on Windows — or double backslashes (\\). -
Run the script in R (or
source("copyR.R")in your project).
The script will:- Copy the specified file(s) or folder(s) to the destination
- Overwrite existing files if they already exist
- Print a success or error message in the console
-
If the copy fails, check:
- That the source file or folder exists
- That the destination folder path is correct
- That you have the necessary write permissions
Example use case:
You have a data project that depends on a dataset from another repo.
When the dataset gets updated, just run:
source("copyR.R")and your local copy will stay up to date automatically.