Title: bypy实现服务器与百度网盘文件互传

Author: Songbing He

Date: 2025-08-08

Reference: https://github.com/houtianze/bypy

1. 安装软件

pip install bypy

WARNING: The script bypy is installed in ‘/data2/home/xxx/.local/bin’ which is not on PATH.

# 添加环境变量(无warning可跳过)
echo 'export PATH=~/.local/bin:$PATH' >> ~/.bashrc
source ~/.bashrc # 永久生效
echo $PATH # 检查是否添加成功
# 检查是否安装成功
bypy -V # v1.8.9

2. 百度网盘授权

bypy info

在这里插入图片描述

复制链接至浏览器获取授权码

在这里插入图片描述

3. 基本命令

bypy是百度网盘的Python客户端,支持文件列表、下载、上传、比较、向上同步、向下同步等操作。由于百度PCS API权限限制,仅能操作百度网盘我的应用数据/bypy目录。

# list the 'remotepath' directory at Baidu PCS 查看文件列表
bypy ls [remotepath]

# create a directory at Baidu Yun 新建文件夹
bypy mkdir <remotedir>

# delete a file / dir remotely at Baidu Yun 删除文件
bypy rm <remotepath>

# download a remote directory (recursively) 下载文件
bypy download [remotepath] [localpath]

# upload a file or directory (recursively) 上传文件
bypy upload [localpath] [remotepath]

# remotepath: remote path at Baidu Yun (after app root directory), if not specified, it is set to the root directory at Baidu Yun
# localpath: local path at Linux. if not specified, it is set to the current directory
# 解绑
# Linux服务器端解绑
bypy -c
# 百度网盘端解绑
https://passport.baidu.com/accountbind?tpl=
Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐