'Copying only nested folders
I think this is a problem with a simple fix but I keep hitting dead ends. I have a folder, let's call it "A", containing many subfolders. Each subfolder contains files. I want to copy the subfolders within A to a different folder, not the folder A itself. I have tried the below, but it just ends up pasting folder A into my new_folder_path. What am I missing here?
file.copy(folder_A_path,new_folder_path, recursive = T)
Solution 1:[1]
You need to get the names of the files/dirs to copy:
file.copy(
from = list.files(path = folder_A_path, full.names = T),
to = new_folder_path,
recursive = TRUE
)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Gregor Thomas |
