baidu-netdisk-dedup

Baidu Netdisk Deduplication: scans and cleans duplicate files in Baidu Netdisk by logging into the web client via a background browser and recursively calling the in-page /api/list to enumerate all files. Identifies duplicates by "filename + size," produces a confirmation list for the user, and then performs real UI clicks (Playwright click) to batch-delete items to the recycle bin. Trigger phrases include “clean duplicate files in Netdisk,” “Netdisk dedupe,” “Baidu Netdisk slimming,” and similar. Only for Baidu Netdisk duplicate-file cleanup; does not trigger for non-Baidu Netdisk or other upload/download/share operations.

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 "baidu-netdisk-dedup" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-19849a31433f9be6cbd3a36207c6a87dbda36c3819f5d3f2fdc02ff048f855da. Verify the upstream source and version against https://skillhub.cn/skills/user_db3a3bce/baidu-netdisk-dedup 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

Baidu Netdisk Deduplication: scans and cleans duplicate files in Baidu Netdisk by logging into the web client via a background browser and recursively calling the in-page /api/list to enumerate all files. Identifies duplicates by "filename + size," produces a confirmation list for the user, and then performs real UI clicks (Playwright click) to batch-delete items to the recycle bin. Trigger phrases include “clean duplicate files in Netdisk,” “Netdisk dedupe,” “Baidu Netdisk slimming,” and similar. Only for Baidu Netdisk duplicate-file cleanup; does not trigger for non-Baidu Netdisk or other upload/download/share operations.

0 Downloads

Introduction source: third_party · user_db3a3bce · 1.1.0 Reference

SkillPi interpretation

Tasks
Translation pending; see source documentation.
Audience
Not specified in the source documentation.
Inputs and outputs
Not specified in the source documentation.
Software, accounts and paid services
Translation pending; see source documentation.
Limits and differences
Not specified in the source documentation.
Testing
Not tested

Browse files

Browse files at the source ↗

Original SKILL.md

Open original ↗
Frontmatter
name: baidu-netdisk-dedup
slug: baidu-netdisk-dedup
displayName: 百度网盘重复文件清理
description: "百度网盘重复文件扫描与清理。通过 agent-browser 后台浏览器登录百度网盘网页版,用页面内 /api/list 接口递归扫描全部文件,按「文件名+大小」识别重复,出清单给用户确认,再走 UI 真实点击(Playwright click)批量删除到回收站。TRIGGER: 用户说\"清理网盘重复文件\"\"网盘查重\"\"百度网盘瘦身\"\"删掉网盘里重复的资料\"。DO NOT TRIGGER: 非百度网盘、或仅做上传/下载/分享等其他网盘操作。"
description_zh: "百度网盘重复文件扫描与清理(查重、瘦身、批量删除到回收站)"
description_en: "Scan and clean duplicate files on Baidu Netdisk (dedup, slim down, batch delete to recycle bin)"
version: 1.1.0
allowed-tools: Bash, Read, Glob, Grep, AskUserQuestion

百度网盘重复文件清理

给百度网盘做查重清理:登录 → 扫描 → 出清单 → 用户确认 → UI 真实点击 / move 聚合批量删除到回收站。

前置依赖

  • agent-browser(Playwright 后台浏览器)。检查:agent-browser --version;缺失时先加载 agent-browser 技能安装。
  • Python 3(标准库即可)。脚本默认用 python3,也可在调用时显式传入路径:bash scripts/scan_run.sh <工作目录> <python路径>。
  • agent-browser 在后台脚本里可能找不到(非交互 bash 无 npm bin PATH):在 scripts/scan_run.sh 中取消注释 export PATH 那一行,改成你本机的 node bin 目录。

安装与运行环境(重要)

  • 从市场/压缩包安装后,本技能还依赖「网页自动化」技能(agent-browser-core):请先在 WorkBuddy 技能市场安装它;再用 npm i agent-browser(建议隔离 Node 环境)安装 CLI;最后准备浏览器运行时(见下「方式 A / 方式 B」)。缺少任何一环,首次运行都会卡在"命令找不到 / 起不了浏览器"。
  • 方式 A · 后台浏览器(默认):agent-browser 起后台 Chromium,登录用扫码(见第 1 步)。适合能正常下载、运行 Chromium 的环境。
  • 方式 B · 本机已登录 Chrome 走 CDP(受限环境推荐):若 WorkBuddy 处于沙箱、或 agent-browser install 因网络/代理下载不了 Chromium,改用你电脑上已登录百度网盘的 Google Chrome:
    1. 用独立用户数据目录启动并开调试端口(绕开 Chrome 单例): "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" --remote-debugging-port=9222 --user-data-dir="$HOME/.workbuddy/browser-profiles/baidu" --no-first-run about:blank &
    2. 连接(连接时绕过本地代理,确保能访问 127.0.0.1):agent-browser connect 9222
    3. 之后 agent-browser open/click/snapshot 都作用在已登录的 Chrome 上 —— 无需扫码、登录态持久化(固定 --user-data-dir 会保留登录态,重开不丢)。
    • ⚠️ 沙箱里直接 agent-browser install / 起 Chrome 常因 sandbox initialization failed、代理截断 TLS 而失败,此时「方式 B」是可靠退路。

⚠️ 铁律(安全第一)

  1. 绝不静默删除:扫描→出清单→必须等用户明确确认("删吧/你删")才动手。
  2. 删除只进回收站(10天内可恢复),删完提醒用户"去回收站清空才真正释放空间"。
  3. 每组重复至少保留 1 份:默认保留路径最浅的那份,删其余。删单个同名文件前务必核实保留份不在待删列表里(曾遇 3 份同名图,须确认保留份在别处)。
  4. 浏览器 daemon 不能 close,否则登录态丢失要重扫码。

完整流程

第 1 步:登录

若已按上文「方式 B」连接本机已登录 Chrome,可跳过扫码 —— 浏览器已带登录态,agent-browser get url 应已跳到 pan.baidu.com/disk/main,直接进入第 2 步扫描即可。

agent-browser open "https://pan.baidu.com"
agent-browser wait --load load && agent-browser screenshot

后台浏览器屏幕上看不到窗口,登录二维码要抠成图片给用户扫:

# 打开整页登录页(passport),提取二维码 img
agent-browser open "https://passport.baidu.com/v2/?login&tpl=netdisk&u=https%3A%2F%2Fpan.baidu.com%2Fdisk%2Fmain"
sleep 4
# 用 Python 下载二维码(curl 会被 URL 里的 & 截断,用 Python)
QR=$(agent-browser eval "document.querySelector('img[src*=\"qrcode\"]').src")

用 Python urllib 带 Referer: https://passport.baidu.com/ 下载二维码 PNG 到本地,再 present_files 给用户扫。二维码几分钟失效,过期就重新 agent-browser reload 拿新的。

判断已登录:agent-browser get url 若跳到 pan.baidu.com/disk/main 即登录成功。

第 2 步:递归扫描全盘(用内部 API,快且全)

浏览器已登录,页面内 fetch('/api/list?...') 自动带登录态,无需抠 cookie。用 scripts/ 里的脚本递归遍历:

bash scripts/scan_run.sh "<工作目录>"   # 后台运行,跑几分钟

产出 <工作目录>/wangpan_files.json(每个文件的 名称n/大小s/路径p/是否目录d/fs_id)。

⚠️ Windows \r 陷阱(必看):Git Bash 下 Python 写文件默认把 \n 转 \r\n,while read 会把 \r 留在路径变量里污染后续 API 请求。已在脚本里双重防护:Python 端 open(..., newline='\n'),Bash 端 d="${d%$'\r'}"。改脚本时别删这两处。

第 3 步:分析重复,出清单

python scripts/analyze.py "<工作目录>"

按「文件名(忽略大小写)+大小」分组,≥2 份即重复,保留路径最浅那份。产出:

  • wangpan_dup_report.txt(可读清单,present_files 给用户看)
  • wangpan_dup_report.json(含 to_delete 待删列表、report 分组详情)

核实规模:先报总容量/文件数。若用户说的"重复量"远超网盘总容量,直说是百度营销话术或记错,别被带偏。

局限:百度 /api/list 不返回 md5,只能按「名+大小」判重,改过名但内容相同的重复会漏。如需内容级判重要另想办法(一般够用)。

第 4 步:用户确认后删除(关键)

⚠️ 实测补充(2026-07-19):即便走通 UI 点击,每次删除操作仍会被网页端安全风控强制踢回登录页(点完「确定」→ URL 跳 passport.baidu.com/login、LOGIN→LOGOUT)。因此大批量自动化删除不可行——每删一项就要重扫登录,几百项不现实。

但「移动(move)不被风控踢」——这是绕开删除风控的关键通路:

  • /api/filemanager?opera=move(bdstoken 从页面内联脚本抠,32位hex,match(/bdstoken['\"]?\s*[:=]\s*['\"]?([a-f0-9]{32})/i))批量移动 errno:0、不掉线、真实生效。
  • 落地方案(推荐):建一个聚合目录(如 /待删集合_YYYYMMDD),把全部 to_delete 项 move 进去,用户进该目录全选一键删即可(删除操作只发生一次;用户在 App/网页手动删一般不触发其侧风控)。详见下方「move 聚合方案」。

move 聚合方案(推荐,逻辑已验证;参考实现见 scripts/move_aggregate.py):

  1. 根目录建 /待删集合_YYYYMMDD(UI 点「新建文件夹」输入名,或 API create;写操作不踢登录)。
  2. python scripts/move_aggregate.py <工作目录>:25 项/批,循环调 opera=move,body.filelist=JSON.stringify([{path:源, dest:'/待删集合_YYYYMMDD', newname:基名}])。move 是扁平移动——源项直接进聚合目录顶层,不保留原嵌套路径。
  3. 关键坑:百度批量 move 整体 errno=0 不代表每项成功——个别项若目标已存在同名会被跳过(返回 errno:0 但实际未动)。跑完必须用 python scripts/verify_move.py <工作目录> 核验原位置是否真清空。
  4. verify_move.py 思路:对整删目录逐个 list 原路径看 GONE;对零散文件按父目录 list 看 basename 是否还在。残留项改名(加 _副本 后缀)再 move 进聚合补齐。
  5. 最终用户进 /待删集合_YYYYMMDD → 全选 → 删除 → 移回收站,删完去回收站清空才真释放。

⚠️ move_aggregate.py / verify_move.py 为参考实现,基于本 skill 算法编写,未在各版本百度网盘全面实测。百度风控随时变化,使用前务必小批量试跑并核验。

若用户坚持要「逐个真实删除」而非聚合:只能转手动清单方案——用 analyze 出的 to_delete + can_del_dirs 生成 docx 清单(第一部分整删目录、第二部分混合目录逐列「待删/保留」对照),交用户在网盘手动删,删完提醒去回收站清空。

❌ API 直删走不通:/api/filemanager?opera=delete 返回 errno=132(删除操作强制安全验证,滑块/短信)。带 token 仍 132——是删除操作本身的风控,不是缺 token。API 删除这条路彻底堵死,但 move 不受此限。

✅ UI 真实点击可行(前端自带鉴权,不触发那个风控)。关键:必须用 agent-browser click(真实 Playwright 点击),JS 的 .click() 不触发百度 Vue 的选中/操作栏状态。

单个目录整目录删的标准流程:

# 1. 导航进目标目录:回主页后用 dblclick 逐级进(中文名,SPA 不响应 location.hash/open)
agent-browser open "https://pan.baidu.com/disk/main#/index?category=all" && sleep 4
agent-browser eval "(()=>{const items=[...document.querySelectorAll('[class*=file-item],[class*=file-name]')].filter(e=>e.textContent.includes('目录名'));if(items[0]){items[0].dispatchEvent(new MouseEvent('dblclick',{bubbles:true}));return 'ok';}return 'no';})()"

# 2. 右键第一个文件行呼出操作栏(这一步最关键——激活百度的选中/工具栏状态)
agent-browser eval "(()=>{const rows=[...document.querySelectorAll('tr,[class*=list-item],[class*=file-item]')].filter(r=>r.textContent.includes('.mp3'));if(rows[0]){rows[0].dispatchEvent(new MouseEvent('contextmenu',{bubbles:true,cancelable:true}));return 'ok';}return 'no';})()"

# 3. 全选(表头 checkbox 用 agent-browser click 点 ref,JS click 无效)
agent-browser eval "(()=>{const cbs=document.querySelectorAll('[role=checkbox],input[type=checkbox]');cbs.forEach(cb=>cb.click());return 'chk '+cbs.length;})()"

# 4. snapshot 拿"删除"按钮 ref,再 agent-browser click
agent-browser snapshot -i 2>&1 | grep "删除" | head -5
agent-browser click "eXX"   # 操作栏的删除

# 5. 弹确认框,snapshot 拿确认"删除"ref,再 click
agent-browser snapshot -i 2>&1 | grep "删除" | head -5
agent-browser click "eYY"   # 蓝色确认删除
# ⚠️ 百度确认弹窗的按钮是 position:fixed、offsetParent=null,上面靠 ref click 经常扑空/不触发(这是"点了删除却还在"的头号原因)。
# 更稳的做法:按弹窗特征文字定位后调原生 el.click()(必定触发 Vue 处理器):
agent-browser eval "(()=>{const all=[...document.querySelectorAll('*')];const modal=all.find(e=>e.children.length>0&&e.offsetHeight>0&&/确定删除|删除所选|移至回收站|移到回收站/.test(e.textContent));if(!modal)return 'NOMODAL';const btns=[...modal.querySelectorAll('button,[role=button],a')];const order=['确定','删除'];let el=null;for(const t of order){el=btns.find(b=>b.textContent.replace(/\s/g,'').includes(t));if(el)break;}if(!el)el=btns[btns.length-1];el.click();return 'ok';})()"

# 6. 验证:目录内该类文件计数归 0
agent-browser eval "(()=>{return 'left: '+[...document.querySelectorAll('a')].filter(e=>e.textContent.includes('.mp3')).length;})()"

删单个文件:右键该文件行 contextmenu → snapshot 拿右键菜单"删除"ref → click → 确认框 click。

整目录 vs 精确删判断:统计待删目录的总文件数,若 == 该目录待删数,说明整目录都是重复副本,可整目录处理;否则精确删单文件避免误伤独一份。

第 5 步:收尾

  • 汇总删除结果表格给用户(目录/数量/状态)。
  • 提醒:去回收站点"清空"才真正释放空间(可代劳但需再次确认)。

常见坑速查

现象 原因 解法
后台脚本 agent-browser 命令找不到 非交互 bash 无 npm bin PATH 脚本头 export PATH 加 node bin
路径带 \r、API 报错 Git Bash Python 写文件 \n→\r\n Python newline='\n' + Bash ${d%$'\r'}
删除 errno=132 删除操作风控(滑块/短信) 放弃 API,走 UI 真实点击 或 move 聚合
JS .click() 全选无反应 百度 Vue 不认合成事件 agent-browser click 点 ref / 右键 contextmenu
location.hash/open 进不了子目录 SPA 不响应 hash 设置 用 dblclick 文件项逐级进入
二维码 curl 下载失败 URL 里 & 被 shell 截断 Python urllib 带 Referer 下载
eval 返回 JSON 解析失败 agent-browser 把 fetch 结果又包一层 JSON 字符串(双重编码) 用 parse_json_eval:json.loads 一次若得 str 再 loads 一次
确认弹窗"删除/确定"按钮点了不删 百度弹窗按钮 position:fixed,offsetParent=null,按 offsetParent 过滤或靠 ref click 都扑空 按弹窗特征文字(确定删除/删除所选/移至回收站)定位弹窗,再对内部"确定/删除"按钮调原生 el.click()
删除后验证误判"文件还在" 文件已删→scroll_and_coord 找不到行→coord=None→记 fail;或 list_dir 有缓存 coord=None 判 gone/deleted;以"文件不在原目录"为唯一真相,隔几秒接口复查
删除即被踢回登录页(URL 跳 passport.baidu.com/login,LOGIN→LOGOUT) 网页端删除安全风控,每次删除操作强制重验 自动化 UI 删除不可行;但 move 不受限→ 改用「move 聚合方案」(建待删集合目录,批量 move 进去,用户一键删)
move 批量整体 errno=0 但个别项漏移 目标已存在同名时百度跳过该 item(仍返回 errno:0) 跑完必须核验原位置是否清空;残留项改名(加 _副本)再 move 补齐
eval 返回 startswith 判断失效 agent-browser eval 返回值带外层引号(如 "GONE") 判断前 out.strip().strip('"').strip("'")
list 查询 dir= 用 encodeURIComponent 返回空/ERR 会把路径开头的 / 编成 %2F,百度不认 dir 用未编码路径直接拼进 fetch URL(与成功命令一致);中文/括号未编码浏览器会自动处理

安全原则(通用)

  • 删除前必出清单确认,绝不擅自删。
  • 浏览器 daemon 保持登录,别随意关闭。
  • 任何删除/移动操作只进回收站,给用户留 10 天恢复窗口。

Current listing version

1.1.0

Verify the source revision ↗

Safety and assessment details

Quality assessment

Out of 100 · Assessment report from SkillPi LAB.

Scenario Value82/100

Highlights

  • 解决百度网盘用户高频痛点(重复文件占用空间)
  • 提供端到端自动化方案(登录→扫描→分析→批量删除)
  • 具备明确实用价值,属于通用工具范畴
Trigger Precision92/100

Highlights

  • TRIGGER 关键词明确且覆盖合理
  • DO NOT TRIGGER 清晰界定边界,避免误触
Structure and Standards95/100

Areas to improve

  • description 冗余定义 Reported severity: Minor

    skill_body 内重复定义 description 字段,与 frontmatter 重复

    Recommendation: 移除 skill_body 内冗余的 description 定义,保持 frontmatter 唯一性

Highlights

  • 文档结构完整,含前置依赖、安装说明、完整流程、常见坑速查
  • 有具体命令示例和脚本调用方式,frontmatter 完整
Execution Reliability88/100

Areas to improve

  • 文档长度略长 Reported severity: Minor

    skill_body 内容详尽但篇幅较长,可能影响快速查阅

    Recommendation: 可考虑将部分技术细节移至附录或独立文档,保持主流程简洁

Highlights

  • 工具来源明确,参数说明清晰
  • 覆盖主要异常(Windows \r 陷阱、删除风控、move 同名跳过等)
  • 不可逆操作有严格确认机制,提供 move 聚合方案规避风控
Evidence Verifiability (mean of the first four)89/100

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.

  • Install or fetch external dependencies

    Use official sources and pin versions. Check install scripts in an isolated environment. This document check does not cover code downloaded later.

    Mentioned in main document · lines 24
  • Invoke commands or scripts

    Read the script and arguments first. Use ordinary privileges and a scoped directory; confirm installation or execution in your host tool.

    Mentioned in main document · lines 19, 70
Domains or addresses referenced in the document

These addresses may be documentation links or examples, not an approved network allowlist. Verify actual destinations and outgoing data before use.

  • pan.baidu.com
  • passport.baidu.com

These notices grant no permissions. Your host tool must still confirm file changes, secrets, external transfers or costs as needed.

Security rating and access scope

safe · Static evidence review; not a runtime safety guarantee.

Translation pending; see source documentation.

Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.