File and Folder Labels - Files Only

Hello,

I couldn't find any topics regarding the issue I'm encountering for this setting. When I created the "file or folder color assignment" I chose "Files only". However, if the folder name has the same "wildcard" (in this case the word "proposal" using regular expressions) every file within that folder is labeled (colored) the same. If I change the folder name so that it does not include the wildcard, then only the files with that wildcard within that changed folder name is labeled appropriately.

I'm I misunderstanding how this feature should work? It works great for extensions!

The wildcard pattern is applied to the whole path, and by default regular expression will find a match anywhere in the target string. So if the path contains the word "proposal" it will be a match even if the filename isn't.

One way around it is to anchor the regex to the end of the string, by adding a $ to the end of the pattern.

Thanks Jon! I will try that. However, what is the point of the "Files only" type? I thought that selection would limit the parameter to "files only".

It doesn't seem to be doing what I would like it to do. The anchor is placing limits on the entire string (regardless of type) when the limit I want placed is that it's not of a type folder. I will see if I can restrict it based on some files extensions that I have my proposals saved as.

Files Only means only files will be affected by the label.

It has no effect on which parts of a file's path is considered by the wildcard or regular expression.

If you want to match "proposal" only in the name and not the rest of the path, use this regular expression:

\[^\]proposal[^\]$

Thanks Leo! That seems to work. However, I would not have ever figured out that "complex" expression. Based on your first and second statement, the expression you provided is only for the current path, correct?

There are two concepts at play here.

The "Files Only" flag is working as intended, since your folders are not being affected by the label, only your files. If it wasn't working, the folder with "proposal" in its name would also have its color changed.

The second concept is that of which files the filter is actually applied to. This is determined by the wildcard pattern. By default, regular expressions match anywhere within the string. So a regex of "foo" would match "foo" but it would also match "c:\blah\blah\foo\blah\blah".

To solve the problem, you need to tighten up the regex so that it only matches filenames at the end of the path. This is what Leo's suggested pattern will do.

Thanks for the explanation guys. Please consider this thread closed. (Jon, I was going to say that you are up early, but you're in Melbourne. I nearly forgot how large Australia is. My friends in Perth are just now getting ready for work.)

Perth is a long way behind Melbourne, in more ways than one :wink: