目标:
使用 日本阿里云的 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() {echoread -p "按回车键继续..." key
}# loading BDUSS
read_bduss() {if [ ! -f "$BDUSS_FILE" ]; thenecho "错误: BDUSS文件不存在: $BDUSS_FILE"return 1fiBDUSS=$(cat "$BDUSS_FILE")if [ -z "$BDUSS" ]; thenecho "错误: BDUSS文件内容为空"return 1fiecho "$BDUSS"return 0
}show_main_menu() {clear_screenecho "=== BaiduPCS-Go 主菜单 ==="echo "1. 账号管理"echo "2. 文件操作" echo "3. 分享/转存"echo "4. 回收站"echo "5. 系统设置"echo "0. 退出"echo "===================="
}show_account_menu() {clear_screenecho "=== 账号管理 ==="echo "1. 使用BDUSS登录"echo "2. 切换账号"echo "3. 退出账号" echo "4. 显示当前账号"echo "5. 显示账号列表"echo "9. 返回主菜单"echo "0. 退出"echo "===================="
}show_file_menu() {clear_screenecho "=== 文件操作 ==="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_screenecho "=== 分享/转存 ==="echo "1. 分享文件/目录"echo "2. 列出已分享"echo "3. 取消分享"echo "4. 转存分享文件"echo "9. 返回主菜单"echo "0. 退出"echo "===================="
}show_recycle_menu() {clear_screenecho "=== 回收站 ==="echo "1. 列出回收站"echo "2. 还原文件/目录"echo "3. 清空回收站"echo "9. 返回主菜单"echo "0. 退出"echo "===================="
}show_config_menu() {clear_screenecho "=== 系统设置 ==="echo "1. 显示配置"echo "2. 修改配置"echo "3. 恢复默认配置"echo "9. 返回主菜单"echo "0. 退出"echo "===================="
}account_operations() {while true; doshow_account_menuread -p "请选择操作 [0-9]: " choicecase $choice in1) # 使用BDUSS登录clear_screenecho "正在从文件读取BDUSS: $BDUSS_FILE"BDUSS=$(read_bduss)if [ $? -eq 0 ]; thenecho "成功读取BDUSS,正在登录..."BaiduPCS-Go login -bduss="$BDUSS"fipause;;2) # 切换账号 clear_screenBaiduPCS-Go supause;;3) # 退出账号clear_screenBaiduPCS-Go logoutpause;;4) # 显示当前账号clear_screenBaiduPCS-Go whopause;;5) # 显示账号列表clear_screenBaiduPCS-Go loglistpause;;9) # 返回主菜单return;;0) # 退出exit 0;;*)echo "无效的选择"pause;;esacdone
}file_operations() {while true; doshow_file_menuread -p "请选择操作 [0-9]: " choicecase $choice in1) # 列出文件clear_screenread -p "请输入要列出的目录路径(直接回车列出当前目录): " pathif [ -z "$path" ]; thenBaiduPCS-Go lselseBaiduPCS-Go ls "$path"fipause;;2) # 切换目录clear_screenread -p "请输入要切换到的目录路径: " pathBaiduPCS-Go cd "$path"pause;;3) # 下载文件/目录clear_screenread -p "请输入要下载的文件/目录路径: " pathBaiduPCS-Go download "$path"pause;;4) # 上传文件/目录clear_screenread -p "请输入要上传的本地文件/目录路径: " local_pathread -p "请输入要上传到的网盘目录路径: " remote_pathBaiduPCS-Go upload "$local_path" "$remote_path"pause;;5) # 创建目录clear_screenread -p "请输入要创建的目录路径: " pathBaiduPCS-Go mkdir "$path"pause;;6) # 删除文件/目录clear_screenread -p "请输入要删除的文件/目录路径: " pathBaiduPCS-Go rm "$path"pause;;7) # 复制文件/目录clear_screenread -p "请输入要复制的源文件/目录路径: " srcread -p "请输入目标路径: " dstBaiduPCS-Go cp "$src" "$dst"pause;;8) # 移动/重命名clear_screenread -p "请输入要移动/重命名的源文件/目录路径: " srcread -p "请输入新路径: " dstBaiduPCS-Go mv "$src" "$dst"pause;;9) # 返回主菜单return;;0) # 退出exit 0;;*)echo "无效的选择"pause;;esacdone
}share_operations() {while true; doshow_share_menuread -p "请选择操作 [0-9]: " choicecase $choice in1) # 分享文件/目录clear_screenread -p "请输入要分享的文件/目录路径: " pathBaiduPCS-Go share set "$path"pause;;2) # 列出已分享clear_screenBaiduPCS-Go share listpause;;3) # 取消分享clear_screenread -p "请输入要取消的分享ID: " share_idBaiduPCS-Go share cancel "$share_id"pause;;4) # 转存分享文件clear_screenread -p "请输入分享链接: " linkread -p "请输入提取码: " codeBaiduPCS-Go transfer "$link" "$code"pause;;9) # 返回主菜单return;;0) # 退出exit 0;;*)echo "无效的选择"pause;;esacdone
}recycle_operations() {while true; doshow_recycle_menuread -p "请选择操作 [0-9]: " choicecase $choice in1) # 列出回收站clear_screenBaiduPCS-Go recycle listpause;;2) # 还原文件/目录clear_screenread -p "请输入要还原的文件/目录fs_id: " fs_idBaiduPCS-Go recycle restore "$fs_id"pause;;3) # 清空回收站clear_screenecho "警告:该操作将清空回收站!"read -p "确认要清空吗?(y/n) " confirmif [ "$confirm" = "y" ] || [ "$confirm" = "Y" ]; thenBaiduPCS-Go recycle delete -allfipause;;9) # 返回主菜单return;;0) # 退出exit 0;;*)echo "无效的选择"pause;;esacdone
}config_operations() {while true; doshow_config_menuread -p "请选择操作 [0-9]: " choicecase $choice in1) # 显示配置clear_screenBaiduPCS-Go configpause;;2) # 修改配置clear_screenecho "常用配置选项:"echo "1) 设置下载目录: config set -savedir $DEFAULT_DOWNLOAD_DIR" # Changed this lineecho "2) 设置下载并发数: config set -max_parallel <数值>"echo "3) 设置同时下载文件数: config set -max_download_load <数值>"echoread -p "请输入完整的配置命令: " cmdBaiduPCS-Go $cmdpause;;3) # 恢复默认配置clear_screenecho "警告:该操作将恢复所有默认配置!"read -p "确认要恢复吗?(y/n) " confirmif [ "$confirm" = "y" ] || [ "$confirm" = "Y" ]; thenBaiduPCS-Go config resetfipause;;9) # 返回主菜单return;;0) # 退出exit 0;;*)echo "无效的选择"pause;;esacdone
}while true; doshow_main_menuread -p "请选择操作 [0-5]: " choicecase $choice in1) # 账号管理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
结束:
如果今后频繁使用,再去找到相关的应用,或起个项目用编程来实现,现在脚本是最快的方案。
年新快乐~