一个大佬的基于vicer大佬的OneDrive for Business on Bash配合aria2下载自动上传脚本
大佬github地址:https://github.com/lm317379829/OneDrive
现在下载完成后会直接把下载的文件、文件夹直接传到OneDrive根目录。
我现在想传到指定目录(例如upload)该如何修改。

  • #!/bin/bash
  • num="$2"
  • path="$3"
  • downloadpath='/home' #下载目录
  • - if [ $num -eq 0 ]
  • then
  • exit 0
  • fi
  • - function getdir(){
  • IFS=\n';for file in ls "$1"
  • do
  • if [ -d "$1/$file" ]
  • then
  • getdir "$1/$file"
  • else
  • if [ "${1%/*}" = "$downloadpath" ] && [ $num -eq 1 ]
  • then
  • onedrive "$1"
  • elif [ $num -eq 1 ]
  • then
  • onedrive "$1/$file"
  • else
  • onedrive -u "$downloadpath" "$1/$file"
  • fi
  • fi
  • done
  • }
  • - while true; do
  • filepath=$path
  • path=${path%/*};
  • if [ "$path" = "$downloadpath" ]
  • then
  • getdir "$filepath"
  • if [ -d $filepath ]
  • then
  • rm -r "$filepath"
  • else
  • rm "$filepath"
  • fi
  • echo 3 > /proc/sys/vm/drop_caches
  • swapoff -a && swapon -a
  • exit 0
  • fi
  • done复制代码