# How AionUi Performs File Organization and Batch Renaming Using Natural Language Commands

> Discover how AionUi organizes files and performs batch renaming with natural language commands. Automate file operations without manual shell input using AI-parsed intents.

- Repository: [OfficeAI/AionUi](https://github.com/iofficeai/aionui)
- Tags: how-to-guide
- Published: 2026-02-19

---

**AionUi converts natural language instructions into automated file operations by routing AI-parsed intents through an IPC bridge to execute batch renames and folder organization without manual shell input.**

AionUi, developed by iOfficeAI, integrates a conversational AI assistant called **Cowork** that transforms spoken or typed requests into precise filesystem actions. When you ask the assistant to organize files or rename batches of documents, the application parses your intent using the Model Context Protocol (MCP) and translates it into the same secure filesystem calls used by the manual UI. This architecture allows users to manage complex directory structures through simple conversational commands while maintaining the safety and atomicity of traditional file operations.

## Parsing Natural Language into Structured Commands

The file organization process begins in the **Cowork skill definitions** located at [`assistant/cowork/cowork-skills.md`](https://github.com/iOfficeAI/AionUi/blob/main/assistant/cowork/cowork-skills.md). This configuration file defines specific triggers—such as "batch," "rename," and "organize"—that signal the AI to generate a structured command object.

When you submit a request like *"Group all PDFs into a folder called reports"*, the Cowork assistant extracts three key components:

- **action**: The operation type (e.g., `move`, `rename`, `organize`)
- **target**: The file pattern or path (e.g., `**/*.pdf`)
- **params**: Additional specifications (e.g., destination folder, naming patterns)

The MCP protocol serializes this intent into a JSON payload that the renderer process consumes through [`src/renderer/pages/conversation/workspace/hooks/useWorkspaceFileOps.ts`](https://github.com/iOfficeAI/AionUi/blob/main/src/renderer/pages/conversation/workspace/hooks/useWorkspaceFileOps.ts).

## The File Operation Execution Pipeline

Once the AI generates the structured command, AionUi routes the request through a multi-layered bridge architecture that separates UI concerns from filesystem access.

### Command Routing and Hook Initialization

The [`useWorkspaceFileOps.ts`](https://github.com/iOfficeAI/AionUi/blob/main/useWorkspaceFileOps.ts) hook serves as the central coordinator for all file operations triggered by either the AI assistant or manual user actions. This hook exposes methods like `handleBatchRename` that accept an array of operations and manage loading states, error handling, and UI notifications.

The hook validates the incoming command structure and prepares a series of atomic filesystem calls. For batch operations, it groups independent actions (deletes, moves, renames) into a single transaction to minimize UI refreshes.

### IPC Bridge to the Main Process

AionUi uses an **IPC (Inter-Process Communication) bridge** to safely expose Node.js filesystem APIs to the renderer process. The bridge definition in [`src/common/ipcBridge.ts`](https://github.com/iOfficeAI/AionUi/blob/main/src/common/ipcBridge.ts) declares the `renameEntry` provider interface, while the concrete implementation resides in [`src/process/bridge/fsBridge.ts`](https://github.com/iOfficeAI/AionUi/blob/main/src/process/bridge/fsBridge.ts).

The main process handler performs the actual filesystem mutation:

```typescript
// src/process/bridge/fsBridge.ts
ipcBridge.fs.renameEntry.provider(async ({ path: targetPath, newName }) => {
  try {
    const newPath = `${path.dirname(targetPath)}/${newName}`;
    await fs.rename(targetPath, newPath);
    return { ok: true, data: { newPath } };
  } catch (error) {
    console.error('Failed to rename entry:', error);
    return { ok: false, msg: String(error) };
  }
});

```

This separation ensures that dangerous filesystem operations execute only in the privileged main process, while the renderer handles UI state and user feedback.

### Batch Processing and Tree Synchronization

For batch rename operations, the `handleBatchRename` function in [`useWorkspaceFileOps.ts`](https://github.com/iOfficeAI/AionUi/blob/main/useWorkspaceFileOps.ts) executes operations sequentially with timeout protection:

```typescript
// src/renderer/pages/conversation/workspace/hooks/useWorkspaceFileOps.ts
const handleBatchRename = async (operations: Array<{ oldPath: string; newName: string }>) => {
  setRenameLoading(true);
  try {
    for (const op of operations) {
      const resp = await waitWithTimeout(renameWorkspaceEntry(op.oldPath, op.newName));
      if (!resp?.ok) throw new Error(resp?.msg);
    }
    messageApi.success(t('conversation.workspace.contextMenu.renameSuccess'));
    refreshWorkspace();
  } finally {
    setRenameLoading(false);
  }
};

```

After successful execution, [`src/renderer/pages/conversation/workspace/utils/treeHelpers.ts`](https://github.com/iOfficeAI/AionUi/blob/main/src/renderer/pages/conversation/workspace/utils/treeHelpers.ts) recursively updates the file tree data structure, rewriting affected node paths so the explorer UI reflects changes instantly without requiring a full directory rescan.

## Practical Implementation Examples

### Single File Rename via Bridge

The frontend API wrapper in [`workspaceFs.ts`](https://github.com/iOfficeAI/AionUi/blob/main/workspaceFs.ts) provides a typed interface for the IPC bridge:

```typescript
// src/renderer/utils/workspaceFs.ts
export const renameWorkspaceEntry = (path: string, newName: string) =>
  ipcBridge.fs.renameEntry.invoke({ path, newName }) as
    Promise<IBridgeResponse<{ newPath: string }>>;

```

This function returns a promise that resolves with the new file path, allowing the UI to update its internal state optimistically.

### Natural Language to Batch Operation

Consider the user request: *"Rename all files that end with .txt to .md in the notes folder."*

The Cowork skill extracts the following intent:

```json
{
  "action": "rename",
  "target": "notes/**/*.txt",
  "params": { "newExtension": ".md" }
}

```

The UI then builds an operations array mapping each matched file to its new name, passing this array to `handleBatchRename` for execution.

### Fallback Modal Interface

When the AI requires user confirmation or encounters ambiguous parameters, it can programmatically trigger the rename modal defined in [`src/renderer/pages/conversation/workspace/index.tsx`](https://github.com/iOfficeAI/AionUi/blob/main/src/renderer/pages/conversation/workspace/index.tsx):

```tsx
<Modal
  visible={modalsHook.renameModal.visible}
  title={t('conversation.workspace.contextMenu.renameTitle')}
  onCancel={modalsHook.closeRenameModal}
  onOk={fileOpsHook.handleRenameConfirm}
  confirmLoading={modalsHook.renameLoading}
>
  <Input
    autoFocus
    value={modalsHook.renameModal.value}
    onChange={v => modalsHook.setRenameModal(p => ({ ...p, value: v }))}
    placeholder={t('conversation.workspace.contextMenu.renamePlaceholder')}
  />
</Modal>

```

The assistant pre-populates the input field and invokes `handleRenameConfirm`, seamlessly blending conversational AI with traditional GUI workflows.

## Summary

- **AionUi** uses the **Cowork assistant** and MCP protocol to parse natural language into structured file operation commands.
- The **IPC bridge** ([`src/common/ipcBridge.ts`](https://github.com/iOfficeAI/AionUi/blob/main/src/common/ipcBridge.ts) and [`src/process/bridge/fsBridge.ts`](https://github.com/iOfficeAI/AionUi/blob/main/src/process/bridge/fsBridge.ts)) securely executes filesystem mutations in the main process.
- **Batch operations** are orchestrated through [`useWorkspaceFileOps.ts`](https://github.com/iOfficeAI/AionUi/blob/main/useWorkspaceFileOps.ts), which handles sequential execution and error rollback.
- The **file tree** updates recursively via [`treeHelpers.ts`](https://github.com/iOfficeAI/AionUi/blob/main/treeHelpers.ts) to reflect organizational changes immediately.
- Users can trigger the same rename flows conversationally or through manual UI modals, ensuring flexibility in workflow automation.

## Frequently Asked Questions

### How does AionUi understand complex file organization requests?

AionUi relies on the **Cowork skill definitions** in [`assistant/cowork/cowork-skills.md`](https://github.com/iOfficeAI/AionUi/blob/main/assistant/cowork/cowork-skills.md) to identify keywords like "organize," "group," or "batch rename." The Model Context Protocol structures these requests into JSON commands containing the action, target pattern, and parameters, which the frontend translates into specific filesystem calls.

### Is it safe to let AI perform batch renaming operations?

Yes. According to the source code in [`src/process/bridge/fsBridge.ts`](https://github.com/iOfficeAI/AionUi/blob/main/src/process/bridge/fsBridge.ts), all rename operations execute through a hardened IPC bridge that validates paths and returns structured error responses. The batch processor in [`useWorkspaceFileOps.ts`](https://github.com/iOfficeAI/AionUi/blob/main/useWorkspaceFileOps.ts) includes error handling that stops the operation sequence if any individual rename fails, preventing partial or inconsistent states.

### Can I review changes before the AI executes them?

AionUi supports a modal fallback mechanism where the AI can pre-populate the rename dialog defined in [`src/renderer/pages/conversation/workspace/index.tsx`](https://github.com/iOfficeAI/AionUi/blob/main/src/renderer/pages/conversation/workspace/index.tsx). This allows users to review and modify suggested filenames before confirming the operation, combining the speed of natural language input with manual oversight when desired.

### What happens if a natural language command is ambiguous?

The Cowork assistant attempts to extract the most specific intent possible based on the skill triggers. If parameters remain ambiguous, the system defaults to the modal confirmation flow, presenting the interpreted action to the user for verification before invoking `handleRenameConfirm` or related batch operations.