On 08/05/2017 6:59 AM, Archit Soni wrote:> Hey Ben, > > I tried this, > > # identify the folders > current.folder <- "C:/Where my files currently live" > new.folder <- "H:/Where I want my files to be copied to" > > # find the files that you want > list.of.files <- list.files(current.folder, "SDM\\.tif$",full.names=T) > > # copy the files to the new folder > file.copy(list.of.files, new.folder) > > But i am still getting FALSE and files are not getting copied from the > folder. However,if I give a single file name it copies that file to new > folder. > > Any thoughts ?Getting FALSE where? Does list.of.files look right? If it contains any directories, you'll want "recursive = TRUE" in file.copy(). Duncan Murdoch
Hey Duncan, There are no sub folders in the folder which its content i want to copy. Just 4 files. list.files('Old Folder Path') gives me the files in this folder. I am running this line that gives me False when running for all the 4 files file.copy(list.files(oldFolder),newFolder,recursive = TRUE) On Mon, May 8, 2017 at 4:36 PM, Duncan Murdoch <murdoch.duncan at gmail.com> wrote:> On 08/05/2017 6:59 AM, Archit Soni wrote: > >> Hey Ben, >> >> I tried this, >> >> # identify the folders >> current.folder <- "C:/Where my files currently live" >> new.folder <- "H:/Where I want my files to be copied to" >> >> # find the files that you want >> list.of.files <- list.files(current.folder, "SDM\\.tif$",full.names=T) >> >> # copy the files to the new folder >> file.copy(list.of.files, new.folder) >> >> But i am still getting FALSE and files are not getting copied from the >> folder. However,if I give a single file name it copies that file to new >> folder. >> >> Any thoughts ? >> > > Getting FALSE where? > > Does list.of.files look right? > > If it contains any directories, you'll want "recursive = TRUE" in > file.copy(). > > Duncan Murdoch > >-- Regards Archit [[alternative HTML version deleted]]
On 08/05/2017 7:12 AM, Archit Soni wrote:> Hey Duncan, > > There are no sub folders in the folder which its content i want to copy. > Just 4 files.Okay, so you won't need "recursive = TRUE".> > list.files('Old Folder Path') gives me the files in this folder.That's not the same as you typed below. In the script below, does list.of.files contain the right names, with fully specified paths?> > I am running this line that gives me False when running for all the 4 files > > file.copy(list.files(oldFolder),newFolder,recursive = TRUE)The lack of full.names could cause the problem here, if that's not just a typo in this message. Duncan Murdoch> > > > On Mon, May 8, 2017 at 4:36 PM, Duncan Murdoch <murdoch.duncan at gmail.com > <mailto:murdoch.duncan at gmail.com>> wrote: > > On 08/05/2017 6:59 AM, Archit Soni wrote: > > Hey Ben, > > I tried this, > > # identify the folders > current.folder <- "C:/Where my files currently live" > new.folder <- "H:/Where I want my files to be copied to" > > # find the files that you want > list.of.files <- list.files(current.folder, > "SDM\\.tif$",full.names=T) > > # copy the files to the new folder > file.copy(list.of.files, new.folder) > > But i am still getting FALSE and files are not getting copied > from the > folder. However,if I give a single file name it copies that file > to new > folder. > > Any thoughts ? > > > Getting FALSE where? > > Does list.of.files look right? > > If it contains any directories, you'll want "recursive = TRUE" in > file.copy(). > > Duncan Murdoch > > > > > -- > Regards > Archit