Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default rule when no other rule is matching #150

Closed
Rayn2k opened this issue Oct 12, 2021 · 2 comments
Closed

Default rule when no other rule is matching #150

Rayn2k opened this issue Oct 12, 2021 · 2 comments

Comments

@Rayn2k
Copy link

Rayn2k commented Oct 12, 2021

Is there a chance to set a default rule in case no other rule is executed?

I've a set of rules described in the config and then a bunch of files, where these rules have to be used for. I run this as a cron task periodically on a dedicated inbox folder and with the rules the files are moved to several destinations.
My problem is that all files, where no rule matched, stay in the inbox folder and then in the next cron task run they were processed again and again.

I would be pleased, if there is an option to set a default/fallback rule, in case all other rules cannot be matched. Then, my unprocessed file can be moved to a folder "no_rules_available" and I can check, whether I have to create new rules for.

Currently I added a stupid rule at the end of the config file, just for all files, which is then always processed for this movement. But then in all my other rules I get in the logs the message:
" - [Move] ERROR! [Errno 2] No such file or directory: '/source/xyz.pdf' "

I think the reason is that than more than one rule is matching and both are tried to execute. But they cannot moved twice, because the first, real rule has moved the file to the correct destination. This workaround is just my last option, but I don't know, whether the rules are processed in the right order and my "fallback" rule is processed first. Therefore I wanted to have this option explicitely, if possible.

Thanks and kind regards,
Ralf

@tfeldmann
Copy link
Owner

Thank you for reporting this. organize v2 is around the corner where the rules are processed just as written, so this will be possible. I'll keep you updated 👍

@tfeldmann
Copy link
Owner

Hey Ralf, v2.0.0 has just been released.

In this version the rules are worked from top to bottom.

rules:
  - name: "Processing all files starting with B"
    locations: ~/Desktop
    filters:
      - name:
          startswith: "B"
    actions:
      - echo: "Processing"

  - name: "Files that do not match our previous rules"
    locations: ~/Desktop
    actions:
      - echo: "The default action"

Good luck 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants