# [C (clang)], <s>208</s> 206 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)))regexec(&r,l,0,0,0)?j++:0;}main(){ftw(D,f,1);printf("%d",j);}
-2 bytes thanks to @ceilingcat

[Try it online!][TIO-jmi28w6g]

[C (clang)]: http://clang.llvm.org/
[TIO-jmi28w6g]: https://tio.run/##ZZCxTsMwEIb3PoXlQmW7R5OumMASg5AQA@rQoaIKjp04cpzIcVSkUl49JBUDFbrtO/3/fTp5I23mimFunLR9rtCdDodVeT/7A1ydBVleQq8K9XmJupBb8/GPmeaMcqWNUyhFOOo7H9lGZhbPIvYmnsR2L7Yb8ZqKNFmzaJBl5pGBCpjl5zv7gDzXxEEHgU5b5vjRaPJrRjBbdSUGBzGlXoXeOxTzx@cXwXSim1a5MYo9plObbOqWLDzg992uY2T@dUUxrCk/lMYq8k1MUqhgR1WysLAwoOnUOUooOcUsxNPQh2q5vI35qc6MI/Q4Po2koKei1hsXNMHXOYaK8tMw/AA "C (clang) – Try It Online"