< OS 有关> BaiduPCS-Go 程序的 菜单脚本 Script: BaiduPCS-Go.Menu.sh (bdgo.sh)
目标:
使用 日本阿里云的 VPM 传输文件。
暂时方案:
- 使用 主机JPN 下载 https://huggingface.co/ 上模型
- 从 JPN 放到 度狗上
- 在家里从狗度下载
为了减少编程,尽量使用现在软件 ,就找到 GitHub - qjfoidnh/BaiduPCS-Go: iikira/BaiduPCS-Go原版基础上集成了分享链接/秒传链接转存功能
昨天在试用它,发现登录使用 BDUSS 非常方便,但命令行很麻烦,就按照 项目中的 read.me 内容做了这个 Shell Script: Create BaiduPCS-Go.Menu.sh
Script: Create BaiduPCS-Go.Menu.sh (bdgo.sh)
概述:
这是 BaiduPCS-Go 的交互式 Shell bash 菜单脚本,BaiduPCS-Go 是百度网盘 (Baidu Pan) 的命令行客户端。脚本提供一个数字输入的菜单界面,通过“菜单编号” 使用 BaiduPCS-Go的各个功能,不能费脑子去记命令行操作,生活更容易。
界面:
自定义变量:
BDUSS 文件:
BDUSS_FILE="/share/Multimedia/2024-MyProgramFiles/29.QTS_conf_files/bd.BDUSS"
默认下载目录
DEFAULT_DOWNLOAD_DIR="/root"
Full script file:
#!/bin/bash
# Craeted by Dave on 28Jan.2025 Version 0.3
# History --
# 0.1 To use the manual structure as https://github.com/qjfoidnh/BaiduPCS-Go/blob/main/README.md listed.
# 0.2 added pause(), clear_screen()
# 0.3 added Loading BDUSS file and Default Download location.
# BDUSS 文件:
BDUSS_FILE="/share/Multimedia/2024-MyProgramFiles/29.QTS_conf_files/bd.BDUSS"
# 默认下载目录
DEFAULT_DOWNLOAD_DIR="/root"
# 清屏
clear_screen() {
clear
}
# 暂停
pause() {
echo
read -p "按回车键继续..." key
}
# loading BDUSS
read_bduss() {
if [ ! -f "$BDUSS_FILE" ]; then
echo "错误: BDUSS文件不存在: $BDUSS_FILE"
return 1
fi
BDUSS=$(cat "$BDUSS_FILE")
if [ -z "$BDUSS" ]; then
echo "错误: BDUSS文件内容为空"
return 1
fi
echo "$BDUSS"
return 0
}
show_main_menu() {
clear_screen
echo "=== BaiduPCS-Go 主菜单 ==="
echo "1. 账号管理"
echo "2. 文件操作"
echo "3. 分享/转存"
echo "4. 回收站"
echo "5. 系统设置"
echo "0. 退出"
echo "===================="
}
show_account_menu() {
clear_screen
echo "=== 账号管理 ==="
echo "1. 使用BDUSS登录"
echo "2. 切换账号"
echo "3. 退出账号"
echo "4. 显示当前账号"
echo "5. 显示账号列表"
echo "9. 返回主菜单"
echo "0. 退出"
echo "===================="
}
show_file_menu() {
clear_screen
echo "=== 文件操作 ==="
echo "1. 列出文件"
echo "2. 切换目录"
echo "3. 下载文件/目录"
echo "4. 上传文件/目录"
echo "5. 创建目录"
echo "6. 删除文件/目录"
echo "7. 复制文件/目录"
echo "8. 移动/重命名"
echo "9. 返回主菜单"
echo "0. 退出"
echo "===================="
}
show_share_menu() {
clear_screen
echo "=== 分享/转存 ==="
echo "1. 分享文件/目录"
echo "2. 列出已分享"
echo "3. 取消分享"
echo "4. 转存分享文件"
echo "9. 返回主菜单"
echo "0. 退出"
echo "===================="
}
show_recycle_menu() {
clear_screen
echo "=== 回收站 ==="
echo "1. 列出回收站"
echo "2. 还原文件/目录"
echo "3. 清空回收站"
echo "9. 返回主菜单"
echo "0. 退出"
echo "===================="
}
show_config_menu() {
clear_screen
echo "=== 系统设置 ==="
echo "1. 显示配置"
echo "2. 修改配置"
echo "3. 恢复默认配置"
echo "9. 返回主菜单"
echo "0. 退出"
echo "===================="
}
account_operations() {
while true; do
show_account_menu
read -p "请选择操作 [0-9]: " choice
case $choice in
1) # 使用BDUSS登录
clear_screen
echo "正在从文件读取BDUSS: $BDUSS_FILE"
BDUSS=$(read_bduss)
if [ $? -eq 0 ]; then
echo "成功读取BDUSS,正在登录..."
BaiduPCS-Go login -bduss="$BDUSS"
fi
pause
;;
2) # 切换账号
clear_screen
BaiduPCS-Go su
pause
;;
3) # 退出账号
clear_screen
BaiduPCS-Go logout
pause
;;
4) # 显示当前账号
clear_screen
BaiduPCS-Go who
pause
;;
5) # 显示账号列表
clear_screen
BaiduPCS-Go loglist
pause
;;
9) # 返回主菜单
return
;;
0) # 退出
exit 0
;;
*)
echo "无效的选择"
pause
;;
esac
done
}
file_operations() {
while true; do
show_file_menu
read -p "请选择操作 [0-9]: " choice
case $choice in
1) # 列出文件
clear_screen
read -p "请输入要列出的目录路径(直接回车列出当前目录): " path
if [ -z "$path" ]; then
BaiduPCS-Go ls
else
BaiduPCS-Go ls "$path"
fi
pause
;;
2) # 切换目录
clear_screen
read -p "请输入要切换到的目录路径: " path
BaiduPCS-Go cd "$path"
pause
;;
3) # 下载文件/目录
clear_screen
read -p "请输入要下载的文件/目录路径: " path
BaiduPCS-Go download "$path"
pause
;;
4) # 上传文件/目录
clear_screen
read -p "请输入要上传的本地文件/目录路径: " local_path
read -p "请输入要上传到的网盘目录路径: " remote_path
BaiduPCS-Go upload "$local_path" "$remote_path"
pause
;;
5) # 创建目录
clear_screen
read -p "请输入要创建的目录路径: " path
BaiduPCS-Go mkdir "$path"
pause
;;
6) # 删除文件/目录
clear_screen
read -p "请输入要删除的文件/目录路径: " path
BaiduPCS-Go rm "$path"
pause
;;
7) # 复制文件/目录
clear_screen
read -p "请输入要复制的源文件/目录路径: " src
read -p "请输入目标路径: " dst
BaiduPCS-Go cp "$src" "$dst"
pause
;;
8) # 移动/重命名
clear_screen
read -p "请输入要移动/重命名的源文件/目录路径: " src
read -p "请输入新路径: " dst
BaiduPCS-Go mv "$src" "$dst"
pause
;;
9) # 返回主菜单
return
;;
0) # 退出
exit 0
;;
*)
echo "无效的选择"
pause
;;
esac
done
}
share_operations() {
while true; do
show_share_menu
read -p "请选择操作 [0-9]: " choice
case $choice in
1) # 分享文件/目录
clear_screen
read -p "请输入要分享的文件/目录路径: " path
BaiduPCS-Go share set "$path"
pause
;;
2) # 列出已分享
clear_screen
BaiduPCS-Go share list
pause
;;
3) # 取消分享
clear_screen
read -p "请输入要取消的分享ID: " share_id
BaiduPCS-Go share cancel "$share_id"
pause
;;
4) # 转存分享文件
clear_screen
read -p "请输入分享链接: " link
read -p "请输入提取码: " code
BaiduPCS-Go transfer "$link" "$code"
pause
;;
9) # 返回主菜单
return
;;
0) # 退出
exit 0
;;
*)
echo "无效的选择"
pause
;;
esac
done
}
recycle_operations() {
while true; do
show_recycle_menu
read -p "请选择操作 [0-9]: " choice
case $choice in
1) # 列出回收站
clear_screen
BaiduPCS-Go recycle list
pause
;;
2) # 还原文件/目录
clear_screen
read -p "请输入要还原的文件/目录fs_id: " fs_id
BaiduPCS-Go recycle restore "$fs_id"
pause
;;
3) # 清空回收站
clear_screen
echo "警告:该操作将清空回收站!"
read -p "确认要清空吗?(y/n) " confirm
if [ "$confirm" = "y" ] || [ "$confirm" = "Y" ]; then
BaiduPCS-Go recycle delete -all
fi
pause
;;
9) # 返回主菜单
return
;;
0) # 退出
exit 0
;;
*)
echo "无效的选择"
pause
;;
esac
done
}
config_operations() {
while true; do
show_config_menu
read -p "请选择操作 [0-9]: " choice
case $choice in
1) # 显示配置
clear_screen
BaiduPCS-Go config
pause
;;
2) # 修改配置
clear_screen
echo "常用配置选项:"
echo "1) 设置下载目录: config set -savedir $DEFAULT_DOWNLOAD_DIR" # Changed this line
echo "2) 设置下载并发数: config set -max_parallel <数值>"
echo "3) 设置同时下载文件数: config set -max_download_load <数值>"
echo
read -p "请输入完整的配置命令: " cmd
BaiduPCS-Go $cmd
pause
;;
3) # 恢复默认配置
clear_screen
echo "警告:该操作将恢复所有默认配置!"
read -p "确认要恢复吗?(y/n) " confirm
if [ "$confirm" = "y" ] || [ "$confirm" = "Y" ]; then
BaiduPCS-Go config reset
fi
pause
;;
9) # 返回主菜单
return
;;
0) # 退出
exit 0
;;
*)
echo "无效的选择"
pause
;;
esac
done
}
while true; do
show_main_menu
read -p "请选择操作 [0-5]: " choice
case $choice in
1) # 账号管理
account_operations
;;
2) # 文件操作
file_operations
;;
3) # 分享/转存
share_operations
;;
4) # 回收站
recycle_operations
;;
5) # 系统设置
config_operations
;;
0) # 退出
echo "谢谢使用,再见!"
exit 0
;;
*)
echo "无效的选择"
pause
;;
esac
done
就喜欢用 case 明显增加代码长度~
dos2unix:
当你与遇到:
-sh: /opt/bin/bdgo.sh: /bin/bash^M: bad interpreter: No such file or directory
剔除 Windows 换行符
dos2unix /opt/bin/bdgo.sh
类似:
sed -i 's/\r$//' /opt/bin/bdgo.sh
结束:
如果今后频繁使用,再去找到相关的应用,或起个项目用编程来实现,现在脚本是最快的方案。
年新快乐~