> To build or manage a Wix site with an AI agent, follow https://www.wix.com/headless/skill.md
> It builds a new Wix site or puts your own site online, from a prompt, and keeps changing it afterwards. The pages are code in any web technology, and Wix runs the backend.
> It works through the Wix plugin (the Wix MCP and the Wix skills), the Wix CLI or no Wix login, and puts the site live on Wix hosting or on another host.
> Business features include a store, bookings, events and tickets, a restaurant, a blog, forms, members and many more.
> Read the Wix skills online at https://www.wix.com/skills
> 
> Portal Navigation:
> 
> - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version.
> - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages).
> - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`).
> - If a reference page seems to be missing its schema (parameters, return types, or type definitions), append `?schema=true` to its `.md` URL (e.g. `https://dev.wix.com/docs/contexts/contexts/stores/category-info/use-category-info-context.md?schema=true`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt

# Method name: updateFolder(_id: string, folder: UpdateFolder, options: UpdateFolderOptions)

# Method package: wixMediaV2

# Method menu location: wixMediaV2 --> folders --> updateFolder

# Method Link: https://dev.wix.com/docs/velo/apis/wix-media-v2/folders/update-folder.md

# Method Description:

Updates a folder. <br />

You can use the `parentFolderId` parameter to move a folder from its current parent folder to a different parent folder.



# Method Code Examples:

*** Note: do not assume any prop names or enum values other than the ones in the example.

## Update a folder's name (dashboard page code)

```javascript
import { folders } from 'wix-media.v2';

/* Sample id value: '7984b3c5454e4371aqbd4f4eedde96bc'
 *
 * Sample folder value:
 * {
 *   displayName: 'mountains'
 * }
 */

async function myUpdateFolderFunction(id, options) {
  try {
    const updatedFolder = await folders.updateFolder(id, options);

    console.log(`Updated folder ${updatedFolder.displayName}:`, updatedFolder);
    return updatedFolder;
  } catch (error) {
    console.error(error);
    // Handle the error
  }
}

/* Promise resolves to:
 * {
 *   "_createdDate": "2023-08-21T09:32:34.000Z",
 *   "_id": "7984b3c5454e4371acbd4f4eedde96bc",
 *   "_updatedDate": "2023-08-21T11:10:51.000Z",
 *   "displayName": "mountains",
 *   "parentFolderId": "103601562ec94214bee61f470b403dd5",
 *   "state": "OK"
 * }
 */
```

## Update a folder's name (export from backend code)

```javascript
import { Permissions, webMethod } from 'wix-web-module';
import { folders } from 'wix-media.v2';
import { elevate } from 'wix-auth';

/* Sample id value: '7984b3c5454e4371aqbd4f4eedde96bc'
 *
 * Sample folder value:
 * {
 *   displayName: 'mountains'
 * }
 */

export const myUpdateFolderFunction = webMethod(Permissions.Anyone, async (id, options) => {
  try {
    const elevatedUpdateFolder = elevate(folders.updateFolder);
    const updatedFolder = await elevatedUpdateFolder(id, options);

    console.log(`Updated folder ${updatedFolder.displayName}:`, updatedFolder);
    return updatedFolder;
  } catch (error) {
    console.error(error);
    // Handle the error
  }
});

/* Promise resolves to:
 * {
 *   "_createdDate": "2023-08-21T09:32:34.000Z",
 *   "_id": "7984b3c5454e4371acbd4f4eedde96bc",
 *   "_updatedDate": "2023-08-21T11:10:51.000Z",
 *   "displayName": "mountains",
 *   "parentFolderId": "103601562ec94214bee61f470b403dd5",
 *   "state": "OK"
 * }
 */

```

## Update a folder's location 

```javascript
/************************************
 * Backend code - create-folder.web.js *
 ***********************************/

import { Permissions, webMethod } from 'wix-web-module';
import { folders } from 'wix-media.v2';
import { elevate } from 'wix-auth';

export const listFolders = webMethod(Permissions.Anyone, async () => {
  try {
    const elevatedListFolders = elevate(folders.listFolders)
    const foldersList = await elevatedListFolders();

    return foldersList;
  } catch (error) {
    console.error(error);
  }
});

export const updateFolder = webMethod(Permissions.Anyone, async (id, options) => {
  try {
    const elevatedUpdateFolder = elevate(folders.updateFolder);
    const updatedFolder = await elevatedUpdateFolder(id, options);

    return updatedFolder;
  } catch (error) {
    console.error(error);
  }
});

/*************
 * Page code *
 ************/

import { updateFolder, listFolders } from 'backend/create-folder.web';

$w.onReady(async () => {
  await populateFoldersDropdowns();

  $w('#updateFolderLocation').onClick(async () => {
    const folderId = $w('#updateFolderDropdown').value;
    const parentFolderId = $w('#parentFolderDropdown').value;
    if (folderId === parentFolderId) {
        $w('#folderIsParentFolderMsg').show();
        return;
    };
    const options = {parentFolderId};
    const updatedFolder = await updateFolder(folderId, options);

    console.log(`Successfully updated folder ${updatedFolder.displayName}:`, updatedFolder);
    $w('#updateFolderSuccessMsg').show();
  });
});

async function populateFoldersDropdowns() {
  const folders = await listFolders();
  const dropdownOptions = folders.map((folder) => {
    return {
      label: folder.displayName,
      value: folder._id
    };
  });

  $w('#updateFolderDropdown').options = dropdownOptions;
  $w('#parentFolderDropdown').options = dropdownOptions;
};

```

---