Title: Function to rename files
Last modified: September 15, 2018

---

# Function to rename files

 *  Resolved [Jordy Meow](https://wordpress.org/support/users/tigroumeow/)
 * (@tigroumeow)
 * [7 years, 8 months ago](https://wordpress.org/support/topic/function-to-rename-files/)
 * Hi,
 * I am the developer of Media File Renamer and would love to see a “Rename” function
   in your plugin. Right now your plugin handles add, and delete, but many users
   rename files using my plugin and I would love to recommend them your plugin. 
   Right now, I can’t 🙁 If you add it, I will definitely add support for your plugin
   in mine.
 * Thanks 🙂

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [interfacelab](https://wordpress.org/support/users/interfacelab/)
 * (@interfacelab)
 * [7 years, 8 months ago](https://wordpress.org/support/topic/function-to-rename-files/#post-10691444)
 * I probably wouldn’t add this to Media Cloud, mostly because I only add features
   my clients request or need for a given build.
 * However, you could add this to your plugin, fairly easily I think. Off the top
   of my head you’d have to:
    - Detect if media cloud plugin was activated via `is_plugin_active('ilab-media-
      tools')`
    - The `\ILAB\MediaCloud\Tools\ToolsManager::instance()` is the entry point into
      the plugin itself. You won’t have to include/require any files as it should
      autoload.
    - Determine if cloud storage is enabled and activated by doing something like`\
      ILAB\MediaCloud\Tools\ToolsManager::instance()->toolEnabled('storage')`
    - If it’s enabled, you can get the storage interface via `\ILAB\MediaCloud\Tools\
      ToolsManager::instance()->tools['storage']`
    - Once you have the storage interface, you can copy a file to a new one and 
      delete the old one. Refer to `classes/Cloud/Storage/StorageInterface.php` 
      for the method signatures, but it’d only be two calls.
    - The data for storage is held in an array in an attachment’s meta (you can 
      fetch with `wp_get_attachment_metadata($id)` called `s3`. Use and update the
      values in that.
 * I think that’s all you’d have to do to get it working.
 * In theory 😉
    -  This reply was modified 7 years, 8 months ago by [interfacelab](https://wordpress.org/support/users/interfacelab/).
    -  This reply was modified 7 years, 8 months ago by [interfacelab](https://wordpress.org/support/users/interfacelab/).
 *  Plugin Author [interfacelab](https://wordpress.org/support/users/interfacelab/)
 * (@interfacelab)
 * [7 years, 8 months ago](https://wordpress.org/support/topic/function-to-rename-files/#post-10691462)
 * Also, one thing to note is that you’d have to rename all the images size ONLY
   if Imgix wasn’t being used. If Imgix is enabled, the plugin disables any thumbnail
   generation that WordPress might do, relying on Imgix to do that. So, in that 
   case, if Imgix is enabled you only have to rename a single file.
 *  Plugin Author [interfacelab](https://wordpress.org/support/users/interfacelab/)
 * (@interfacelab)
 * [7 years, 8 months ago](https://wordpress.org/support/topic/function-to-rename-files/#post-10691487)
 * It looks like my reply is being held in moderation for some reason.
 * Do let me know if you implement this and I will add a blurb to the read me/plugin
   page about it.
 * Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Function to rename files’ is closed to new replies.

 * ![](https://ps.w.org/ilab-media-tools/assets/icon.svg?rev=2795439)
 * [Media Cloud for Bunny CDN, Amazon S3, Cloudflare R2, Google Cloud Storage, DigitalOcean and more](https://wordpress.org/plugins/ilab-media-tools/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/ilab-media-tools/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/ilab-media-tools/)
 * [Active Topics](https://wordpress.org/support/plugin/ilab-media-tools/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/ilab-media-tools/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/ilab-media-tools/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [interfacelab](https://wordpress.org/support/users/interfacelab/)
 * Last activity: [7 years, 8 months ago](https://wordpress.org/support/topic/function-to-rename-files/#post-10691487)
 * Status: resolved