I am aware that the File Paths module allows administrators to use tokens to set patterns for renaming files, but as of writing (Jan 2015) there are more than 100 bugs in the queue and no updates to the dev version in almost one year. (I also installed it and it and was unable to get it working.) So, I want to do this programmatically.
My goal is to rename all new user-uploaded image files on my Drupal 7 site to this pattern:
[uid of logged in user][timestamp].extension.
Being able to rename them with the UID is very important because these files are often downloaded and exchanged (sent back and forth via email, without reference to Drupal), and we need an easy way to identify which user originally uploaded the file after it has been downloaded from the site.
I am using the Transliteration module. For inspiration, I also took a look at the File Entity Paths module, but it didn't provide me any insight. I further consulted this article on file-naming best practices from Acquia but it provides no suggestions for doing this programmatically.