That’s right.
Please read the post to its very end:
Thanks.
If I understand your proposal correctly, it’s an “all-in-one” approach that can be used either:
- as a standalone script (i.e. outside a Smart Rule), or
 - inside a Smart Rule, where both the screening and the filename editing happen within the “Perform the following actions” section
 
In the latter case, the first part of the rule (“All/any of the following are true”) would do very little—perhaps only filter by file type (which your script already handles)—so it wouldn’t really leverage the full capabilities of Smart Rules ?
Apologies if these questions seem basic; I’m still a beginner, so thanks for your patience ![]()
Yes, the script does basically all that you’d otherwise do in a smart rule: It selects the files you want to work on and then works on them.
I see very little point in using a smart rule for that task, since it should be a one-time process. After the files are renamed, what would you need the smart rule (or the script) for, anyway?
As it is written now, it can’t be used in a smart rule; that would require some modifications.
Thanks for confirming my understanding.
I am using the rule (or the script) now - to process the documents which are already in my archive - and will reuse it on a regular basis to process new files as soon as I receive them.
For now—until my familiarity with the tools improves and I’m more confident about avoiding mistakes—I prefer to rely on Smart Rules. Their two-stage structure lets me first verify that the filtering condition really matches my intentions, and only once I’m sure I apply the rule “on demand” - to actually modify the selected file(s).
In parallel, I’ll study your suggested approach so that I can move to it later, once I feel I’ve grasped the basics more firmly and gained more confidence.
Thanks again for your support.
For a smart rule, use this code:
function performsmartrule(records) {
records.filter(r => !r.name().match(/^\d{4}-\d\d-\d\d/)).forEach(r => {
      r.tags = r.tags().concat('Fix Filename')
  })
}
What I said previously about changing the code to modify the name, too, is still valid.
As you can see, there’s very little gained by the smart rule, since you can’t use it to select records whose names don’t start with a date (as has been confirmed by @cgrunenberg and @BLUEFROG). The only thing a smart rule can do for you in this context is select the kind of documents.