How to count .raw file number in folders?

I have data, that contains:

FOLDER1(Results) --> FOLDER2(Batch1, Batch2, ..., Batch10, Reservoir1, Reservoir2, Reservoir3) --> FOLDER3(ID4985-1, ID4985-2, ID4985-3, ect.) --> RAW(ID4985-1, ID4985-2, ID4985-3, ect.)

I need to have a result or table that would give a count of raw files in each FOLDER3, something like this:
FOLDER2 FOLDER3 no. of .raw files
BATCH1 ID4985-1 4
BATCH1 ID4985-1 0
BATCH1 ID4985-1 2
BATCH1 ID4985-1 4
BATCH1 ID4985-1 4
.... .... ....

Is there any script or workflow that would help me accomplish this? Kinda amateur on R so any input, advise or answer would help. Thanks a lot!

Hi Torbuttone,
Welcome to the forum.

If I understand what you want this should do the job for each sub-folder, one at a time.

library(purrr)

my_files <- list.files(
    path = "path/to/your/files/",
    pattern = "*",
    full.names = TRUE
)
length(my_files)

You may need to install purr first.

install.packages("purr")
1 Like

I'll try giving that a try, thanks!

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.