How can I create a custom column and get a conditional word as text?

Hello community!

I am using the following code $if($eql($strstr(%_folderpath%,Archived),0),Archived,Not) to create a custom column named "State" and assigns the word "Archived" if the folder path of the file contains the word "Archived".

Now, I want to assign the words "Archived", "Uncategorized", or "Unchecked" if the folder path of the file contains any of these words. If none of these words are present in the folder path, I want to assign the word "Nothing". Is this possible?

Thank you for your time!

Something like
$ifgreater($strstr($replace(%_folderpath%,Archived,xxxxx,Uncategorized,xxxxx,Unchecked,xxxxx),xxxxx),0,Nothing,-)

I can't make it work... :slightly_frowning_face:
Can you please explain what this line of code does, part by part?

It checks whether there is a string xxxxx somewhere in the %_Folderpath% after the keywords you have supplied have been replaced by xxxxx.
Your description lacks what should be done if there is no hit - I assumed the - as a good display.

You can test the expression in Convert>Tag-Tag and see whether it produces the correct result or what the difference between the code and the data could be.
Screenshots help a lot.

For the general proceeding:
If you want to treat the file afterwards - wouldn't a filter be much easier to handle? It is not clear to me what you do with the data in the new column.

The basic formula would be
$ifgreater($strstr(%_folderpath%,Archived),0,found,not found)
If the position of the word Archived in the current folderpath will be greater then 0, then return found, else return not found.

As you like to see at least 4 possible variants, you would have to cascade this formula.
This becomes pretty illegible:
$ifgreater($strstr(%_folderpath%,Archived),0,found1,$ifgreater($strstr(%_folderpath%,Uncategorized),0,found2,$ifgreater($strstr(%_folderpath%,Unchecked),0,found3,everything else)))

1 Like

It worked!!! :slight_smile:

After I broke it, it became more readable and understandable...

$ifgreater($strstr(%_folderpath%,Archived),0,found1,
$ifgreater($strstr(%_folderpath%,Uncategorized),0,found2,
$ifgreater($strstr(%_folderpath%,Unchecked),0,found3,
everything else)))

I edited it and then I just had to make it one line again in order to place it into the "Value" field.

Thank you very much both for your help!!! :slight_smile:

1 Like

I have a small issue...

When it prints found1 into "State" column everything is fine. But when it prints found2 looks like this "__found2" and for found3 like this "____found3". It adds two spaces for found2 and four spaces for found3. Any idea why is this happening?

I added lines just to demonstrate the spaces.

You have to check your code for extra spaces following commas. If you look at @LyricsLover 's original code, there is not a single space.

1 Like

You are right 100%!!! Thank you very much!!! :slight_smile:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.