Copy folders from one directory to another in R

前端 未结 3 1233
孤独总比滥情好
孤独总比滥情好 2021-02-18 13:06

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?

3条回答
  •  春和景丽
    2021-02-18 13:58

    I am late. This is my simple approach that gets things done. In R,

    current_folder <- "C:/Users/Bhabani2077/Desktop/Current"
    new_folder <- "C:/Users/Bhabani2077/Desktop/Ins"
    list_of_files <- list.files(current_folder, ".py$") 
    # ".py$" is the type of file you want to copy. Remove if copying all types of files. 
    file.copy(file.path(current_folder,list_of_files), new_folder)
    

提交回复
热议问题