This requires no “AI”, just some simple rule-based automation, at most some algorithmic sorting.
Android (or some custom branded Android versions?) automatically save downloaded files in folders by Pictures, Documents, etc unless you tell them.not to.
Office365 offers the PowerAutomate function, but knowing Microsoft they probably overcomplicated things a bunch. [Edit: obviously this isn’t FLOSS, just a hint at what to look for alternatives to…]
This approach never appealed to me as I want to know where things are rather than where some subroutine thinks it belongs, but I’m certain you will find plenty of software that offers an auto sorting feature.