2008-04-18

Determine File Extensions in Use

The following Mathematica code defines a function that lists all of the file extensions in use in a directory tree:

FileExtensionsInUse[directory_] := Module[{pattern="."~~Except["."|$PathnameSeparator]..~~EndOfString},
  StringCases[#, x:pattern:>x] /. {{}->"", {x_}:>x} & /@
  Select[FileNames["*", directory, Infinity], !StringFreeQ[#, pattern]&] //
  Union
]