# rename()

## Rename a file or folder

&#x20; <mark style="background-color:orange;">rename()</mark> &#x20;

This method is used to rename a file or folder.

{% tabs %}
{% tab title="OneDrive" %}

### **Parameters**

<table><thead><tr><th width="215">Name</th><th width="93">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>$id</code></td><td>string</td><td>ID of the entry that should be updated.</td></tr><tr><td><code>$name</code></td><td>string</td><td>The new name of the entry.</td></tr></tbody></table>

### **Return**

<table><thead><tr><th width="194">Name</th><th width="166">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>$node</code></td><td><strong>CachedNode</strong></td><td>The object for the patched file.</td></tr></tbody></table>

### **Usage**

```php
WPCP_ONEDRIVE_API::set_account_by_id('8c9bacda0-d8d8-4b22-b634-7b5281687575');
WPCP_ONEDRIVE_API::set_drive_by_id('b!DlaHWskCed_MIid3KpJH5Lbatf9HsdXBAZH5YcvPAbMhJUKzTJyzgvXZYpBS');

// Patch the file or folder
$node = WPCP_ONEDRIVE_API::rename('01EXLSWHWMQZNDMLRG7NFIWAVYCFJAXP2R', 'Another picture.jpg');
```

{% endtab %}

{% tab title="Google Drive" %}

### **Parameters**

<table><thead><tr><th width="206">Name</th><th width="113">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>$id</code></td><td>string</td><td>ID of the entry that should be updated.</td></tr><tr><td><code>$name</code></td><td><strong>string</strong></td><td>The new name of the entry.</td></tr></tbody></table>

### **Return**

<table><thead><tr><th width="184">Name</th><th width="167">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>$node</code></td><td><strong>CachedNode</strong></td><td>The object for the patched file.</td></tr></tbody></table>

### **Usage**

```php
WPCP_GDRIVE_API::set_account_by_id('201096615285735764133')

// Patch the file or folder
$node = WPCP_GDRIVE_API::rename('1wzWlDMsZkA4N5yEEAmMigp52u7M0Lk_7', 'Another picture.jpg');
```

{% endtab %}

{% tab title="Dropbox" %}

### **Parameters**

<table><thead><tr><th width="206">Name</th><th width="136">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>$entry</code></td><td>Entry</td><td>The entry that should be updated.</td></tr><tr><td><code>$name</code></td><td><strong>string</strong></td><td>The new name of the entry.</td></tr></tbody></table>

### **Return**

<table><thead><tr><th width="184">Name</th><th width="167">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>$node</code></td><td><strong>CachedNode</strong></td><td>The object for the patched file.</td></tr></tbody></table>

### **Usage**

```php
WPCP_DROPBOX_API::set_account_by_id('dbid:AADSy6JxzbgqCs4A43CAAAfO9xvZwpcsLU');

// Get metadata for the file or folder
$entry = WPCP_DROPBOX_API::get_entry('id:4tUAwPCAdf0b0AAAAA_iw');

// Rename the file or folder
$entry = WPCP_DROPBOX_API::rename($entry, 'New name.jpg');
```

{% endtab %}

{% tab title="Box" %}

### **Parameters**

<table><thead><tr><th width="209">Name</th><th width="96">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>$id</code></td><td>string</td><td>ID of the entry that should be updated.</td></tr><tr><td><code>$name</code></td><td>array</td><td>The new name of the entry.</td></tr><tr><td><code>$is_dir</code></td><td>bool</td><td>Is the entry a folder or a file?</td></tr></tbody></table>

### **Return**

<table><thead><tr><th width="210">Name</th><th width="146">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>$node</code></td><td><strong>CachedNode</strong></td><td>The object for the patched file.</td></tr></tbody></table>

### **Usage**

```php
WPCP_BOX_API::set_account_by_id('29232154182');

// Patch the file or folder
$node = WPCP_BOX_API::rename('51142665', 'Another picture.jpg', false);
```

{% endtab %}
{% endtabs %}
