Question: I would like to get all the files in a directory *without* a given extension. To get them with that extension is quite simple:

```
FileNames["*.<myExt>", myDir]

```

But instead I want everything *except* `"*.<myExt>"` and for reasons beyond the purview of this question I can't just post-process.

So what should I do?

Answer: 
We will use a [`RegularExpression`](https://reference.wolfram.com/language/ref/RegularExpression.html) trick since Mathematica's built-in string patterns seem to be failing.

The idea is poached from here: <https://stackoverflow.com/a/406408/5720002>

```
noExtRegex[ext : _String | {__String}] :=
 RegularExpression@
  TemplateApply[
   "[^\\.]*\\.((?!``).)*",
   If[Length@Flatten@{ext} > 1,
     "(" <> # <> ")" &,
     Identity
     ]@
    StringRiffle[Flatten@{ext}, "|"]
   ]

```

This will match anything of the pattern `"*.<except ext>"`.

Here's it in action:

```
FileNames[
    "*",
    FileNameJoin@{$InstallationDirectory, "SystemFiles", "FrontEnd"},
    ∞
    ] // Map[FileExtension] // DeleteDuplicates // Sort

{"", "nb", "nbp", "png", "tiff", "tr"}

FileNames[
    noExtRegex["tr"],
    FileNameJoin@{$InstallationDirectory, "SystemFiles", "FrontEnd"},
    ∞
    ] // Map[FileExtension] // DeleteDuplicates // Sort

{"nb", "nbp", "png", "tiff"}

```

We can see we dropped the `"tr"` extension. The pattern used unfortunately matches anything containing the string you supply, so we get this somewhat unfortunate result:

```
FileExtension /@
   FileNames[
    noExtRegex["n"],
    FileNameJoin@{$InstallationDirectory, "SystemFiles", "FrontEnd"},
    ∞
    ] // DeleteDuplicates // Sort

{"tiff", "tr"}

```

To make this suck less we can supply a list of the extensions we want to avoid, which then only hurts us when one extension is contained within another

```
FileExtension /@
   FileNames[
    noExtRegex[{"nb", "tr"}],
    FileNameJoin@{$InstallationDirectory, "SystemFiles", "FrontEnd"},
    ∞
    ] // DeleteDuplicates // Sort

{"png", "tiff"}

```
How about simply

```
Complement[FileNames["*",myDir], FileNames["*.<myExt>",myDir]]

```

Or would you call this "post-processing"?