How can I change a file before save in programmatically?
My best guess is to use hook_field_presave() to alter it before it gets saved, for example:

function hook_file_presave($file) {
  // Change the file timestamp to an hour prior.
  $file-&gt;timestamp -= 3600;
}


See also: How do I change the uploaded file name after the node has been saved?