How can I change a file before save in programmatically? I want to upload an audio file on Drupal, trim it, and save it in sites/default/files/audio/. I know how I trim the audio file; I only want to set my audio-trim-library in Drupal when the file is uploaded, and not when saved.

How can I do it?
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?