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
maybe you could try this regex:
(.)*(COC04){1}(.)*(.pdf)$
The breakdown:
(.)*
= any character for an unlimited amount of times (also zero)(.)*(COC04)
= After the previous, it has to be followed by COC04 (1 time)(.)*(COC04){1}(.)*
= After finding the COC04, it can be followed by any other string.(.)*(COC04){1}(.)*(.pdf)$
= the string should end with .pdfSo: list.files(pattern = "(.)*(COC04){1}(.)*(.pdf)$" full.names = TRUE, recursive = TRUE)
I hope this helps!