I want to use the R function list.files to search for all text files in a folder and in its subfolders. However, I would like to exclude all files that are in the same subfolder, say, contains unfinished work, which is not ready for what I am using other files for. The structure looks like this:
- folder |- subfolder_1_good_stuff |- subfolder_2_good_stuff |- subfolder_3_good_stuff |- subfolder_4_unfinished_stuff
So, the βfolderβ will be my working directory.
Now I would use:
list.files(path=".", pattern=".txt", recursive=TRUE)
But what should I add to the expression "path" to exclude the folder with the unfinished material. This folder name will not be present in any file names, if that matters.
source share