0

I have found the question answered about file-type/extension here: How do I get Notepad++ to associate a file type with a language?

There is a description about using the Style Configuration to associate a user extension with a language. That has worked great for me in other situations. However, this is different....

We have literally thousands of schemas applied to this database, all with different filenames. The standard for filenames is:

<OWNER>SCHEMA.<NUMBER>.TXT (for example, ADMSCHEMA.414.TXT). It would be great to associate these with SQL, but I do not want every txt file that is opened to be assumed SQL language. If the world were perfect, I would have any file that includes *SCHEMA*TXT to be assumed of the SQL language.

Anyone know if that can be done?

YeeP
  • 1
  • 2
  • An idea: Make a (PowerShell, VBA, etc.) script that checks the file name, and if it matches, renames it with a custom/preferred extension, opens it in Notepad++, and then renames it back, overwriting the original. If it doesn't match it just opens it in Notepad++. Then set that script as the program to open .TXT files with. – Ƭᴇcʜιᴇ007 Feb 18 '14 at 18:01
  • Not so much an answer now, but going-forward, why not just use the .SQL extension instead of them being .TXT? – Kruug Feb 18 '14 at 18:02
  • So... what you're asking for is to have SQL highlighting activated when a file is opened and only when that file has a given file name scheme? So instead of looking at the file name suffix Notepad++ would have to look at the infix. I'm not sure you can do that. That would be highly specialized type of situation. You would have to make a script or something, or an extension. – Samir Feb 18 '14 at 18:04
  • Here's a thought: why not just use whatever file extension you want? – Samir Feb 18 '14 at 18:08

1 Answers1

0

If you are allowed to change the extensions of these files, then you could create your own file extension and associate it with Notepad++. Changing file name extension is not changing the data in those files.

  1. Change ADMSCHEMA.414.TXT to ADMSCHEMA.414.TXT.MVCE.
  2. Associate MVCE with Notepad++.
  3. Start Notepad++ and go to Style Configurator.
  4. Select SQL and type in MVCE in the "User ext" box.
  5. Click Save & Close. Done!

If you do this, I suggest you keep the "TXT" so you have .TXT.MVCE instead of replacing it as in .MVCE. This helps you identify the original file name extension and file type. It's a good practice. It's the same idea as in .tar.gz archive files.

Samir
  • 20,527
  • 74
  • 166
  • 226
  • This way you don't have to code anything, and I think it might just work in your situation. – Samir Feb 18 '14 at 18:21
  • Oh and, just for the record, MVCE stands for *My Very Cute Extension*. It's free to use, I won't claim any royalty fees or anything. ;) – Samir Feb 18 '14 at 18:22