This is a straightforward problem, but I'm missing something below.
I have a very large vector of filepaths (i.e. strings) in R
vec = c("\dir\subdir\pathname1\file.txt", "\dir\subdir\pathname1\file.pdf",
txt_paths <- # single vector only with txt files
pdf_paths <- # single vector only with pdf files
jpg_paths <- # single vector only with jpg files
You can use the logical vector produced by grepl() to index vec.
txt_paths <- vec[grepl(".txt$", vec)]