---
name: Search Files by Type
slug: search-files-by-type
category: Automation
description: Searches for files of a specified type (like .txt or .pdf) in a given directory path. Useful when you need to locate all files of a certain format.
github: "https://github.com/CoderWanFeng/python-office/tree/develop/skills/file/search_specify_type_file"
language: Python
stars: 1331
forks: 297
install: "git clone https://github.com/CoderWanFeng/python-office"
added: 2026-07-20T06:48:44.556Z
last_synced: 2026-07-28T07:00:50.907Z
canonical_url: "https://dirskills.com/skills/search-files-by-type"
---

# Search Files by Type

Searches for files of a specified type (like .txt or .pdf) in a given directory path. Useful when you need to locate all files of a certain format.

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

## README

# search_specify_type_file Skill

> 在当前路径下搜索指定类型的文件

## 功能描述

在指定路径下搜索指定类型的文件。

## 所属分类

`office/skills/file/search_specify_type_file/`

## 调用方式

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

search_specify_type_file(
    file_path='./data',
    file_type='.txt'
)
```

## 参数说明

| 参数 | 类型 | 必填 | 默认值 | 说明 |
|------|------|------|--------|------|
| `file_path` | str | 是 | - | 文件路径 |
| `file_type` | str | 是 | - | 文件类型（如 `.txt`、`.py`） |

## 返回值

`None`（结果直接打印输出）

## 使用示例

```python
from office.skills.file import search_specify_type_file
search_specify_type_file(file_path='./docs', file_type='.pdf')
```

## 原始函数

`office.api.file.search_specify_type_file`
