Reputation: 467
I have a folder (raw_file) that has a bunch of csv files (e.g. aaa.csv, bbb.csv). I need to create another folder (out_put) under the same directory of raw_file. Also, in the out_put folder, it will have folders that has the same name as my csv file (e.g. aaa, bbb). Can anyone show me how do this in R. Thanks in advance.
Upvotes: 1
Views: 1660
Reputation: 697
Assuming (raw_file) is your working directory (so setwd(raw_file)) :
foldernames<-sub("^([^.]*).*", "\\1", list.files())
foldernames<-paste("out_put/",foldernames,sep='')
lapply(foldernames,dir.create,recursive = TRUE)
Upvotes: 5