[R] how to get no of pdf files in a particular directory

Barry Rowlingson b.rowlingson at lancaster.ac.uk
Mon Aug 18 09:22:56 CEST 2008


2008/8/18 Kurapati, Ravichandra (Ravichandra)
<ravichandra.kurapati at alcatel-lucent.com>:

> Dir<-"/var/www/html/celnet/users/cxadmin/FlowDuration_DataVolume/fld_01_
> 08_18_08"
>
>          There will be pdf and/or csv files.

>
>        I want to know how many *.pdf files are  there in that
> directory.

>     How can I get using R commands.
>

 length(list.files(Dir,pattern="\\.pdf$"))

 Note that pattern is a regexp matching .pdf at the end of a string,
not a glob ("*.pdf").

 You could use Sys.glob, but list.files looks easier.

Barry



More information about the R-help mailing list