Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Copy folders from one directory to another in R

Tags:

I have two folders (say "A","B") which are in a folder (say "Input"). I want to copy "A" and "B" to another folder (say "Output"). Can I do this in R?

like image 988
Karan Pappala Avatar asked Jul 27 '15 13:07

Karan Pappala


People also ask

How do I copy files from one directory to another in R?

copy() function as shown in the following R syntax. Within the file. copy function, we have to specify the directory path and file names of the first folder from which we want to copy the files, as well as the directory path and file names of the second folder to which we want to copy the files.

How do I copy an entire folder to another folder?

In order to copy a directory on Linux, you have to execute the “cp” command with the “-R” option for recursive and specify the source and destination directories to be copied.

How do I copy a folder to another directory in terminal?

In the Terminal app on your Mac, use the cp command to make a copy of a file. The -R flag causes cp to copy the folder and its contents. Note that the folder name does not end with a slash, which would change how cp copies the folder.

How do I copy multiple folders into multiple folders?

If you need to copy a file to multiple folders, you can hold down the Ctrl key, and drag the file or folder on to each folder you want to copy it to.


1 Answers

Copying your current directory files to their new directories

currentfiles is a list of files you want to copy newlocation is the directory you're copying to

If you aren't listing your current files, you'll need to loop through you're working directory

file.copy(from=currentfiles, to=newlocation,            overwrite = TRUE, recursive = FALSE,            copy.mode = TRUE) 

This is for deleting your old files

file.remove(currentfiles) 
like image 135
Huang Chen Avatar answered Sep 18 '22 01:09

Huang Chen