local-file-search
Installation
Review the source and dependencies with a prompt. A package is available to download.
Install with an AI assistant
Copy the prompt so your assistant can review the pinned revision and dependencies first.
View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "local-file-search" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-32385aa76f79ba4baaa96738c8d48124430060df616b0b62f791f266dda96f86. Verify the upstream source and version against https://skillhub.cn/skills/user_09381314/local-file-search before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.
Source and setup
skillhub.cn
Setup guidance pending
See the original source for supported tools, dependencies, and permissions.
Installation test pending
Local File Search: search for files whose names or contents contain keywords within a specified Windows directory, supporting common office document types (Word, Excel, PPT, PDF, txt). Executes entirely locally; files are not uploaded to the cloud. Used when users mention searching files, finding documents, or local search.
Introduction source: third_party · user_09381314 · 1.0.0 Reference
SkillPi interpretation
- Tasks
- Translation pending; see source documentation.
- Audience
- Translation pending; see source documentation.
- Limits and differences
- Translation pending; see source documentation.
- Testing
- Not tested
Browse files
Frontmatter
name: local-file-search
description: 在Windows本地指定目录中搜索文件名或文件内容包含关键词的文件,支持Word、Excel、PPT、PDF、txt等常见办公文档;纯本地执行,文件绝不上传云端;用户提及搜文件、找文档、文件搜索、搜索文件内容、本地搜索时使用
version: 1.1.0
category: 办公效率
platforms:
- windows
metadata:
author: 社畜迭代日记
tags:
- 文件搜索
- 本地搜索
- 内容检索
- 办公工具
- Office文档搜索
- PDF搜索本地文件搜索
功能说明
在 Windows 本地磁盘中,按文件名或文件内容搜索包含指定关键词的文件,返回匹配文件的完整路径列表。所有搜索操作在本地执行,文件内容不会上传到任何云端服务器。
支持的文件类型
文件名搜索(全类型支持)
所有文件类型均可按文件名搜索。
文件内容搜索
| 文件类型 | 扩展名 | 搜索方式 |
|---|---|---|
| 纯文本/代码 | .txt .md .py .js .html .css .json .xml .csv .log .yaml .ini .cfg |
PowerShell Select-String 直接读取 |
| Word 文档 | .docx .doc |
COM 对象提取文本后搜索 |
| Excel 表格 | .xlsx .xls |
COM 对象逐单元格读取后搜索 |
| PPT 演示文稿 | .pptx .ppt |
COM 对象提取文本框内容后搜索 |
| PDF 文档 | .pdf |
优先用 Python pdfplumber,否则用 COM 对象 Word 打开 |
适用场景
- 文档太多找不到,只记得里面某个关键词
- 项目文件散落在不同文件夹,需要快速定位
- 搜索合同、标书、报价单等 Office 文档中的关键信息
- 搜索代码文件中包含特定函数名或注释的文件
- 查找包含客户名称、合同编号等关键信息的 PDF 文件
执行步骤
- 确认搜索范围:向用户确认要搜索的目录路径,如果用户未指定,默认搜索当前工作目录
- 确认搜索模式:询问用户是按文件名搜索还是按文件内容搜索
- 按文件名搜索:使用 PowerShell
Get-ChildItem -Recurse搜索文件名,全文件类型支持 - 按内容搜索:根据文件类型分两路执行:
- 文本文件:使用 PowerShell
Select-String直接搜索 - Office/PDF 文件:使用 COM 对象提取文本后匹配关键词
- 文本文件:使用 PowerShell
- 过滤系统目录:自动排除
node_modules、.git、AppData、Windows、ProgramData、Program Files等系统/依赖目录 - 输出结果:以清晰的列表形式展示匹配文件的完整路径,标注文件类型和匹配行,统计匹配数量
搜索逻辑(PowerShell 实现参考)
按文件名搜索(全类型)
$keyword = "用户输入的关键词"
$searchPath = "用户指定的目录"
$excludeDirs = @("node_modules", ".git", "AppData", "Windows", "ProgramData", "Program Files", "Program Files (x86)")
Get-ChildItem -Path $searchPath -Recurse -File -ErrorAction SilentlyContinue `
| Where-Object { $_.Name -like "*$keyword*" } `
| Where-Object { $full = $_.FullName; ($excludeDirs | Where-Object { $full -match "\\$_\\" }).Count -eq 0 } `
| Select-Object FullName, Length, LastWriteTime `
| Format-Table -AutoSize
按内容搜索:文本文件
$keyword = "用户输入的关键词"
$searchPath = "用户指定的目录"
$textExts = @("*.txt", "*.md", "*.py", "*.js", "*.html", "*.css", "*.json", "*.xml", "*.csv", "*.log", "*.yaml", "*.ini", "*.cfg")
Get-ChildItem -Path $searchPath -Include $textExts -Recurse -File -ErrorAction SilentlyContinue `
| Where-Object { $_.FullName -notmatch "\\node_modules\\|\\\.git\\|\\AppData\\|\\Windows\\|\\ProgramData\\|\\Program Files" } `
| Select-String -Pattern $keyword -SimpleMatch `
| Select-Object Path, LineNumber, Line -First 50
按内容搜索:Word 文档(.docx / .doc)
$keyword = "用户输入的关键词"
$searchPath = "用户指定的目录"
$word = New-Object -ComObject Word.Application
$word.Visible = $false
$word.DisplayAlerts = 0
Get-ChildItem -Path $searchPath -Include @("*.docx", "*.doc") -Recurse -File -ErrorAction SilentlyContinue `
| Where-Object { $_.FullName -notmatch "\\node_modules\\|\\\.git\\|\\AppData\\|\\Windows\\|\\ProgramData\\|\\Program Files" } `
| ForEach-Object {
try {
$doc = $word.Documents.Open($_.FullName, $false, $true)
$text = $doc.Content.Text
$doc.Close()
if ($text -match $keyword) {
Write-Output $_.FullName
}
} catch {
# 文件损坏或受保护,跳过
}
}
$word.Quit()
[System.Runtime.InteropServices.Marshal]::ReleaseComObject($word) | Out-Null
按内容搜索:Excel 表格(.xlsx / .xls)
$keyword = "用户输入的关键词"
$searchPath = "用户指定的目录"
$excel = New-Object -ComObject Excel.Application
$excel.Visible = $false
$excel.DisplayAlerts = 0
Get-ChildItem -Path $searchPath -Include @("*.xlsx", "*.xls") -Recurse -File -ErrorAction SilentlyContinue `
| Where-Object { $_.FullName -notmatch "\\node_modules\\|\\\.git\\|\\AppData\\|\\Windows\\|\\ProgramData\\|\\Program Files" } `
| ForEach-Object {
try {
$wb = $excel.Workbooks.Open($_.FullName)
$found = $false
foreach ($ws in $wb.Worksheets) {
$usedRange = $ws.UsedRange
$rows = $usedRange.Rows.Count
$cols = $usedRange.Columns.Count
# 只搜索前 1000 行,避免大文件卡死
for ($r = 1; $r -le [Math]::Min($rows, 1000); $r++) {
for ($c = 1; $c -le $cols; $c++) {
$cellValue = $usedRange.Cells($r, $c).Text
if ($cellValue -match $keyword) {
Write-Output "$($_.FullName) [工作表: $($ws.Name), 单元格: $( $r )行$($c)列]"
$found = $true
break
}
}
if ($found) { break }
}
}
$wb.Close($false)
} catch { }
}
$excel.Quit()
[System.Runtime.InteropServices.Marshal]::ReleaseComObject($excel) | Out-Null
按内容搜索:PPT(.pptx / .ppt)
$keyword = "用户输入的关键词"
$searchPath = "用户指定的目录"
$ppt = New-Object -ComObject PowerPoint.Application
$ppt.Visible = $false
Get-ChildItem -Path $searchPath -Include @("*.pptx", "*.ppt") -Recurse -File -ErrorAction SilentlyContinue `
| Where-Object { $_.FullName -notmatch "\\node_modules\\|\\\.git\\|\\AppData\\|\\Windows\\|\\ProgramData\\|\\Program Files" } `
| ForEach-Object {
try {
$pres = $ppt.Presentations.Open($_.FullName, $true, $false, $false)
$found = $false
foreach ($slide in $pres.Slides) {
foreach ($shape in $slide.Shapes) {
if ($shape.HasTextFrame) {
$text = $shape.TextFrame.TextRange.Text
if ($text -match $keyword) {
Write-Output "$($_.FullName) [幻灯片: $($slide.SlideIndex)]"
$found = $true
break
}
}
}
if ($found) { break }
}
$pres.Close()
} catch { }
}
$ppt.Quit()
[System.Runtime.InteropServices.Marshal]::ReleaseComObject($ppt) | Out-Null
按内容搜索:PDF 文件
# 方式一:优先检测 Python + pdfplumber(推荐)
$keyword = "用户输入的关键词"
$searchPath = "用户指定的目录"
$hasPython = Get-Command python -ErrorAction SilentlyContinue
$hasPdfplumber = $false
if ($hasPython) {
$checkPdf = python -c "import pdfplumber" 2>&1
$hasPdfplumber = ($LASTEXITCODE -eq 0)
}
if ($hasPdfplumber) {
# 用 Python pdfplumber 提取文本后搜索
$pythonScript = @"
import sys, os
from pathlib import Path
try:
import pdfplumber
except ImportError:
sys.exit(1)
keyword = sys.argv[1].lower()
search_path = sys.argv[2]
for root, dirs, files in os.walk(search_path):
dirs[:] = [d for d in dirs if d not in {'node_modules', '.git', 'AppData', 'Windows', 'ProgramData', 'Program Files', 'Program Files (x86)'}]
for f in files:
if f.lower().endswith('.pdf'):
full_path = os.path.join(root, f)
try:
with pdfplumber.open(full_path) as pdf:
for page in pdf.pages:
text = page.extract_text()
if text and keyword in text.lower():
print(f"{full_path} [第{page.page_number}页]")
break
except:
pass
"@
$pythonScript | python - $keyword $searchPath
} else {
# 方式二:降级到 COM 对象用 Word 打开 PDF(Windows 10+ 支持)
$word = New-Object -ComObject Word.Application
$word.Visible = $false
$word.DisplayAlerts = 0
Get-ChildItem -Path $searchPath -Filter "*.pdf" -Recurse -File -ErrorAction SilentlyContinue `
| Where-Object { $_.FullName -notmatch "\\node_modules\\|\\\.git\\|\\AppData\\|\\Windows\\|\\ProgramData\\|\\Program Files" } `
| Select-Object -First 30 `
| ForEach-Object {
try {
$doc = $word.Documents.Open($_.FullName, $false, $true, $false)
$text = $doc.Content.Text
$doc.Close()
if ($text -match $keyword) {
Write-Output $_.FullName
}
} catch { }
}
$word.Quit()
[System.Runtime.InteropServices.Marshal]::ReleaseComObject($word) | Out-Null
}
输入输出示例
示例1:按文件名搜索
输入:在 D:\项目 里找包含"测试报告"的文件
输出:
搜索目录: D:\项目
搜索模式: 文件名包含"测试报告"
匹配文件数: 3
1. D:\项目\2025Q4\测试报告_v1.docx
2. D:\项目\2025Q4\测试报告_v2.docx
3. D:\项目\归档\测试报告模板.xlsx
示例2:按内容搜索 Office 文档
输入:在 D:\合同 里找内容包含"违约金"的 Word 和 PDF 文件
输出:
搜索目录: D:\合同
搜索模式: 文件内容包含"违约金"
匹配文件数: 4
Word 文档:
1. D:\合同\2025年度\采购合同_v3.docx
2. D:\合同\2025年度\服务协议.docx
Excel 表格:
3. D:\合同\统计\违约金汇总.xlsx [工作表: Sheet1, 单元格: 5行3列]
PDF 文件:
4. D:\合同\扫描件\租赁合同.pdf [第8页]
示例3:按内容搜索代码文件
输入:在 D:\代码 里找内容包含"数据库连接"的文件
输出:
搜索目录: D:\代码
搜索模式: 文件内容包含"数据库连接"
匹配文件数: 5
1. D:\代码\src\config.py (第12行)
2. D:\代码\src\database.py (第3行)
3. D:\代码\docs\架构说明.md (第45行)
...
注意事项
- 仅支持 Windows 系统,依赖 PowerShell 和 COM 对象
- Office 文档搜索需要本机安装 Microsoft Office(Word/Excel/PowerPoint)
- PDF 搜索:优先使用 Python + pdfplumber(速度快),未安装 Python 时降级到 Word COM 打开(需 Office 2013+)
- Excel 搜索限制:每张表最多搜索前 1000 行,超大表格可能遗漏
- 搜索大目录时可能需要较长时间,建议用户尽量缩小搜索范围
- 自动排除的目录:node_modules、.git、AppData、Windows、ProgramData、Program Files
- COM 对象搜索速度较慢,Office 文档搜索比纯文本搜索慢 10-50 倍,请告知用户耐心等待
- 安全承诺:所有搜索在本地执行,文件内容和路径不会上传到任何云端服务
Current listing version
1.0.0
Quality assessment
Out of 100 · Assessment report from SkillPi LAB.
Highlights
- 解决办公场景中文件搜索的核心痛点,支持多种文档格式内容搜索
- 纯本地执行保障隐私,文件绝不上传云端
- 支持Word、Excel、PPT、PDF、txt等常见办公文档搜索
Highlights
- 触发词精准完整,覆盖'搜文件''找文档''文件搜索''搜索文件内容''本地搜索'等多种变体
- 边界清晰,不易与其他Skill重叠
Highlights
- Phase/步骤清晰,有出口条件,含端到端示例
- frontmatter完整,单文件≤500行
- 文档结构清晰,易于理解执行流程
Areas to improve
-
Excel搜索限制1000行 Reported severity: Minor
Excel搜索限制每张表最多搜索前1000行,超大表格可能遗漏重要内容
Recommendation: 建议增加对超大表格的警告提示,或提供分页搜索选项
Highlights
- 工具来源明确,参数正确,覆盖主要异常
- 不可逆操作有确认机制
- 自动排除系统目录,避免误操作
The arithmetic mean of the first four original scores, rounded to a whole number.
Static text checks
100 / 100 · skillpi-20261123-no-r3-v1
No current rules matched the text.
This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.
Permissions and checks before use
Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.
These common operations were not identified in the main document. This does not mean no permissions or risks exist.
Security rating and access scope
safe · Static evidence review; not a runtime safety guarantee.
Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.
User discussion
No verified reviews yet.