@saniyaka, Other way would be,
Reference : (This is only for .Xlsx files change it as per your requirement )
Get the files count from a particular folder
Regards, Dominic