rregexdplyrpdftools

How to capture files with the same name only with the .pdf extension


enter image description here

I'm using R, because I need to capture files with the same name only with the .pdf extension See the attached image. The file with the extension in excel doesn't interest me. The files have similar names

I tried according to the code below but it returns the files with the excel extension too

pdfs = list.files(pattern="COC04", recursive = TRUE, full.names = TRUE)

I need to filter by COC04 because there are other pdf files that I'm not interested in


Solution

  • maybe you could try this regex:

    (.)*(COC04){1}(.)*(.pdf)$

    The breakdown:

    So: list.files(pattern = "(.)*(COC04){1}(.)*(.pdf)$" full.names = TRUE, recursive = TRUE)

    I hope this helps!