> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/pterodactyl/wings/llms.txt
> Use this file to discover all available pages before exploring further.

# Rename/Move Files

> Rename or move files and directories on the server

## Endpoint

```
PUT /api/servers/:server/files/rename
```

## Authentication

Requires Bearer token authentication via the `Authorization` header.

## Path Parameters

<ParamField path="server" type="string" required>
  The UUID of the server
</ParamField>

## Request Body

<ParamField body="root" type="string" required>
  The root directory for the rename operations (all paths are relative to this)
</ParamField>

<ParamField body="files" type="array" required>
  Array of file rename operations

  <Expandable title="File Object">
    <ParamField body="from" type="string" required>
      Source file path (relative to root)
    </ParamField>

    <ParamField body="to" type="string" required>
      Destination file path (relative to root)
    </ParamField>
  </Expandable>
</ParamField>

## Response

Returns `204 No Content` on success.

## Example Request

<CodeGroup>
  ```bash cURL - Single Rename theme={null}
  curl -X PUT "https://wings.example.com/api/servers/d3aac109-f0fc-4674-b5bc-199bb50e6b88/files/rename" \
    -H "Authorization: Bearer YOUR_TOKEN" \
    -H "Content-Type: application/json" \
    -d '{
      "root": "/",
      "files": [
        {
          "from": "old-config.yml",
          "to": "config.yml"
        }
      ]
    }'
  ```

  ```bash cURL - Multiple Files theme={null}
  curl -X PUT "https://wings.example.com/api/servers/d3aac109-f0fc-4674-b5bc-199bb50e6b88/files/rename" \
    -H "Authorization: Bearer YOUR_TOKEN" \
    -H "Content-Type: application/json" \
    -d '{
      "root": "/plugins",
      "files": [
        {"from": "OldPlugin.jar", "to": "NewPlugin.jar"},
        {"from": "config/old.yml", "to": "config/new.yml"}
      ]
    }'
  ```

  ```javascript JavaScript theme={null}
  await fetch(
    'https://wings.example.com/api/servers/d3aac109-f0fc-4674-b5bc-199bb50e6b88/files/rename',
    {
      method: 'PUT',
      headers: {
        'Authorization': 'Bearer YOUR_TOKEN',
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        root: '/',
        files: [
          { from: 'world', to: 'world_backup' },
          { from: 'world_nether', to: 'world_nether_backup' }
        ]
      })
    }
  );
  ```

  ```python Python theme={null}
  import requests

  requests.put(
      'https://wings.example.com/api/servers/d3aac109-f0fc-4674-b5bc-199bb50e6b88/files/rename',
      headers={'Authorization': 'Bearer YOUR_TOKEN'},
      json={
          'root': '/',
          'files': [
              {'from': 'server.log', 'to': 'server.log.bak'}
          ]
      }
  )
  ```
</CodeGroup>

## Behavior

* Operations are performed concurrently for better performance
* Both files and directories can be renamed/moved
* Moving to a different directory requires the full path in the `to` field
* If the source file doesn't exist, the operation is skipped (no error)
* Parent directories in the destination path are created automatically
* Ignored files (`.pteroignore`) cannot be renamed or moved
* Path traversal is prevented

<Warning>
  If the destination file already exists, the operation will fail with a 400 error.
</Warning>

## Error Responses

<AccordionGroup>
  <Accordion title="400 Bad Request">
    Destination file already exists
  </Accordion>

  <Accordion title="401 Unauthorized">
    Missing or invalid Bearer token
  </Accordion>

  <Accordion title="403 Forbidden">
    File is on the ignore list or path traversal attempt
  </Accordion>

  <Accordion title="404 Not Found">
    Server does not exist
  </Accordion>

  <Accordion title="422 Unprocessable Entity">
    Empty files array provided
  </Accordion>

  <Accordion title="500 Internal Server Error">
    Failed to rename file (permission error, etc.)
  </Accordion>
</AccordionGroup>

## Use Cases

* Rename configuration files
* Move files between directories
* Organize server files into folders
* Create backup copies (rename to .bak)
* Batch rename operations

## Source Reference

Implementation: `router/router_server_files.go:94-158` (putServerRenameFiles function)
