1

I have a directory containing 70 other sub-directories with different CSV files. CSV files in each directory look like this Modified2-3.csv, added2_3.csv, Retired4_5.csv. My end result is to join all CSV starting with the name Modified but before that How can I loop through all subdirectories selecting only files starting with modified

I have tried this method but it says the character is zero

list.files(pattern = "^Modified.*name.csv")

I do want my result is a list of modified CSV looking like this Modified2_3.csv, Modified3_4.csv,Modified7_8.csv

LivingstoneM
  • 1,088
  • 10
  • 28
  • 3
    `"^Modified.*\\.csv$"` https://stackoverflow.com/questions/4736/learning-regular-expressions – jogo Aug 26 '19 at 08:24

1 Answers1

3

You should be able to go through them without a loop with the use of list.files()'s recursive argument.

list.files(pattern = "^Modified", recursive=TRUE)
Jarn Schöber
  • 309
  • 1
  • 8