This will loop through all libraries in all webs in a site collection and look for documents whose last modified date is older than 90 days. I then set this up using a scheduled task in Windows Task Scheduler to run on a recurring basis to keep documents in the correct location.