node-directory-tree icon indicating copy to clipboard operation
node-directory-tree copied to clipboard

How can i filter files with specific multi extensions

Open joshmpaka opened this issue 3 years ago • 2 comments

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

joshmpaka avatar Aug 27 '21 05:08 joshmpaka

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?

mihneadb avatar Sep 01 '21 17:09 mihneadb

Regex name filtering definitely does seem more viable.

joshmpaka avatar Sep 02 '21 09:09 joshmpaka