I think the best way to do this is to take no more than the first X bytes from the file (X may be 256, 512, etc.), count the number of characters that are not used by ASCII files (ascii codes are allowed: 10, 13, 32-126). If you know for sure that the script is written in English, no character can be outside the specified set. If you are not sure about this language, you can allow no more than Y char to be outside the set (if X is 512, I would choose Y 8 or 10).
If this is not enough, you can use more restrictions, such as: depending on the syntax of the files, such keywords should be present (for example: there should be some kind of echo for your batch files, for, if, goto, call, exit, etc. d.)
source share