---
name: Add Filename Prefix
slug: add-prefix-to-filenames
category: Automation
description: Automates renaming files by adding a consistent prefix to each filename, useful for organizing batches of files quickly.
github: "https://github.com/CoderWanFeng/python-office/tree/develop/skills/file/file_name_add_prefix"
language: Python
stars: 1331
forks: 297
install: "git clone https://github.com/CoderWanFeng/python-office"
added: 2026-07-20T06:48:42.821Z
last_synced: 2026-07-28T07:00:49.894Z
canonical_url: "https://dirskills.com/skills/add-prefix-to-filenames"
---

# Add Filename Prefix

Automates renaming files by adding a consistent prefix to each filename, useful for organizing batches of files quickly.

**Install:** `git clone https://github.com/CoderWanFeng/python-office`

## README

# file_name_add_prefix Skill

> 批量重命名：给文件名增加前缀

## 功能描述

给指定文件的文件名增加指定的前缀。

## 所属分类

`office/skills/file/file_name_add_prefix/`

## 调用方式

```python
from office.skills.file import file_name_add_prefix

file_name_add_prefix(
    file_path='./test.txt',
    prefix_content='prefix_'
)
```

## 参数说明

| 参数 | 类型 | 必填 | 默认值 | 说明 |
|------|------|------|--------|------|
| `file_path` | str | 是 | - | 文件路径 |
| `prefix_content` | str | 是 | - | 前缀内容 |

## 返回值

`None`

## 使用示例

```python
from office.skills.file import file_name_add_prefix
file_name_add_prefix(file_path='./doc.txt', prefix_content='backup_')
```

## 原始函数

`office.api.file.file_name_add_prefix`
