Automatically Move Files Added to a Folder Based on Its Name

Hi,

I'm using KM since a few days and I'm so absolutely addicted and want to thank all people that have realized such an awesome program. So to my question.

I want an automatic macro that detects a change in an input folder and move the PDF on the basis of its name to a specific folder.

For example a bill goes to the bill folder and a bank document to the bank folder.

I can do it with multiply "if" actions but i want to learn more elegant techniques for future macros.

Thank you for your help.

Kind regards,
Noel

Switch statements are just about a direct upgrade from if statements

2 Likes

To support @vincent_ardern’s statement, I have long since stopped using nested if/then/else actions in favour of the much simpler and easier to maintain Switch action.

2 Likes

Exactly what I was looking for! My macros are much simpler yet. Especially since I know to use the "OR" " | " symbol for multiple conditions. :slight_smile:

True. I didn't know the switch actions, but now I use it regularly. Thanks for answering!

1 Like

Hey @Noel,

Please explain. I don't see that documented anywhere.

-Chris

1 Like

@ccstone

I have seen this "OR" condition from: EXAMPLE: SWITCH action with "OR" conditions (copy-and-paste regular expressions)

I dont use his macro, but I just tried "|" between the condition and it worked!

1 Like

Hey @Noel,

Ah, thank you.

I was overthinking it. That's not a logical OR condition per se – it's the alternation operator of a regular expression. The regular expression in this case can be literal text or a regex pattern. (Technically the pipe separated literal text is a regular expression.)

But it could be much more complex – like:

\b([bB]ank.+?|K.+?zug|Transaktion)\b

The matches condition indicates the parameter is a regular expression.

-Chris

1 Like