0

I am trying to copy Java files by listing them from a folder (guava-master) and sub-folders (that is the reason I used the recursive function) using the code below

filenames <- list.files("C:/Users/shahr/Documents/master_unzip/guava-master/", pattern="*.java", recursive = TRUE)

The above list is fine but then...

I tried to paste them into a new folder using the code below

file.copy(filenames, "C:/Users/shahr/Documents/")

However, the output I receive is FALSE for all the files and I don't see any files being copied. Am I making any mistake?

many thanks.

metaGross
  • 15
  • 1
  • 1
  • 6
  • Try adding `full.names = TRUE` in `list.files` so that the directory information is included. Or setting your working directory to `setwd("C:/Users/shahr/Documents/master_unzip/guava-master/")`. Not sure if you need to preserve the subdirectory structure... – Gregor Thomas Dec 05 '18 at 18:41
  • check this: https://stackoverflow.com/questions/10266963/moving-files-between-folders – YOLO Dec 05 '18 at 18:42
  • @Gregor, Thanks! It worked. :) – metaGross Dec 05 '18 at 18:45

0 Answers0