Menu

editable rules for detecting file type

AndyS01
2008-10-22
2012-11-13
  • AndyS01

    AndyS01 - 2008-10-22

    I need to autodetect 'perl wrapped in batch file' file type

    I need a way to have NPP determine the file type by examining the first couple of lines in the file to be opened.

    I have several Perl scripts that run under MSDOS that are wrapped in BATCH file commands, so the filename extension is .BAT, but the file type is Perl source.

    I can distinguish a .BAT file from a Perl file wrapped in a .BAT file by looking at the second line.  This line always has a Perl command invocation.

    If there were a set of editable rules that define methods for determining a file type, I could say something like this:
    "Look at the second line and if it contains "perl", it's a Perl source file"

    If you need more details, I can provide them.

     
    • Bob Uncle

      Bob Uncle - 2008-10-23

      This is very clear.

      As I understand things though, the file type detection is solely done by file extension. You could always manually change the language when you open the file.