node-directory-tree
node-directory-tree copied to clipboard
How can i filter files with specific multi extensions
I am trying to filter files with multiple extensions like filename.info.mp3.
I have tried extensions: /\.(info|mp3)$/
but this just brings all files that have one or both of those extensions but I only want to filter files with both extensions, not just one of the extensions.
I also tried extensions: /\.info.mp3/
but got an error
Your help would be greatly appreciated
This is a tricky one and is caused (if we are to call it that) by Path.extname. It always returns the extension as starting from the last occurrence of .
. It kind of makes sense, if you had a file.like.this.info.mp3, which would be the extension?
I guess for our specific need we could change the logic to "filename ends with ext" instead of the current way of doing it. But then you may get into other issues.
Probably the simplest thing is to replace the idea of "extension" filtering with something like regex name filtering. Thoughts?
Regex name filtering definitely does seem more viable.