# [C (clang)], 208 bytes

<!-- language-all: lang-c -->

    char i,j,*l;regex_t r;f(n,s,t)char*n;{if(fnmatch("*.sh",n,0))return 0;FILE*f=fopen(n,"r");regcomp(&r,"^\\s*(#|$)",1);while((i=getline(&l,&i,f))^-1)regexec(&r,l,0,0,0)?j++:0;}main(){ftw(D,f,1);printf("%d",j);}

[Try it online!][TIO-jmi13jsj]

[C (clang)]: http://clang.llvm.org/
[TIO-jmi13jsj]: https://tio.run/##ZZBBT4MwFMfv@xRNp6Tt3ga7WtELaEyMB@Nhh2ULlhZKSiGlZCZznx2BeHAx7/Z7@f/fL0@shclsMSy1FabPJbpX/rQpHxZ/gK0zL8pr6GQhv65R53OjP/8x3cwol0pbiRKEw75zoWlEZvAiZO/pc7o7pruP9C1Jk3jLwkGUmUMaKmCGz3eOHjmuiIUOPJ22zPKzVuTXjGC26UoMFiJKnfS9syjiTy@vKVOxalppxyh2mE5toqlbEjjAh/2@Y2T5fUMxbCk/ldpIQnRcSG9GUxIYCDQoSg/rLZ01pJiCBqJp6GO1Wt1F/FJn2hJ6Ht9GElBTVeu09Yrg2xxDRfllGH4A "C (clang) – Try It Online"