Get folder by regex in `list.files()`?

Username

I want to get all *.txt files in the directory ../20180101_Folder.

My code:

theFiles <- list.files(
  path = "../*Folder",
  pattern = "*.txt",
  full.names = TRUE
)

But theFiles ends up being NULL. How do I make theFiles equal to a list of all .txt files in the specified directory?

G5W

list.files will expand ~ in a path, but will not expand wild-cards like *. To use those you need

path=Sys.glob("../*Folder")

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related