How can I rename uploaded files programatically? (auto-rename image files)
Assuming you are talking about the core file functionality, you can modify the filename in hook_file_presave() and modify the filename property.

function mymodule_file_presave($file) {
  $parts = pathinfo($file-&gt;filename);
  $file-&gt;filename = $file-&gt;uid . $file-&gt;timestamp . '.' . $parts['extension'];
}


Drupal will handle changing any other properties that need to be changed.

Some issues to be aware of:


Upload forms will expose the new name to the user after he clicks 'Upload'. It may be confusing to upload a file with a regular filename and see it changed to a string of numbers.
There is a note on the hook_file_presave documentation that the hook "doesn't distinguish between files created as a result of a copy or those created by an upload." If you do need to distinguish, check out the $file->source property or try calling menu_get_object() to figure out if the user is on a page with an upload form or not.
Consider using a dash between the uid and the timestamp for your naming convention. Your timestamps will all start with 1 (until 2033 anyway), and users with UIDs ending in 1 (e.g 11, 21, etc.) will make the filename confusing to read.