Change individual file from public to private and vice-versa Running Drupal 7.  I have two file fields set up: One is public, the other private.  I need to be able to take a file which has been saved as a public file, and switch it to the private file field.  And, vice-versa.  Can someone provide some some advice on this?  Thanks!
I've written an update script to switch a file field from private to public:

function MYMODULE_update_7100(&amp;$sandbox) {
  $field_name = 'MY_FIELD_NAME';

  $fids_data = db_select('field_data_' . $field_name, 'dat')
    -&gt;fields('dat', array($field_name . '_fid'))
    -&gt;execute()
    -&gt;fetchCol();

  $fids_revision = db_select('field_revision_' . $field_name, 'rev')
    -&gt;fields('rev', array($field_name . '_fid'))
    -&gt;execute()
    -&gt;fetchCol();

  $fids = array_unique(array_merge($fids_data, $fids_revision));

  // Move files using Drupal's File API
  $files = file_load_multiple($fids);
  foreach ($files as $file) {
    if ($file &amp;&amp; file_exists($file-&gt;uri)) {
      $destination = str_replace('private:', 'public:', $file-&gt;uri);
      $directory = drupal_dirname($destination);
      if (file_prepare_directory($directory, FILE_CREATE_DIRECTORY|FILE_MODIFY_PERMISSIONS)) {
        file_move($file, $destination, FILE_EXISTS_RENAME);
      }
    }
  }

  // Update field configuration
  $field = field_info_field($field_name);
  $field['settings']['uri_scheme'] = 'public';
  field_update_field($field);
}


What this function simply does:


Gets the fid of all files from field_data and field_revision tables.
Moves files using File API
Updates field configuration