简体   繁体   中英

How move files based on file names in R?

I know the question was asked many times but still i'm copying empty file. let's assume i have 50000k files and i have around 3000 file names as a vector so i want to move the files to different folder based on their names.

for (i in files) {
  for (j in files_names) {
    if ( i == j){
      
          file_copy(i, "C:/copy/to_this_folder")

    }
  }
}

But it moves the files but all of them were 0KB. Can any one please explain this to me

Does this work for you?

letters
x = c("a", "b", "c", "2")
for (name in x[x %in% letters]) {
  file.copy(name, "tmp/")
}

Also, remember to use getwd() to check whether your working directory is correct or not.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM