Aria2下载完成后转移文件到指定目录

原创 楚盟  2019-04-04 03:43  阅读 1,475 views 次

这个脚本的作用就是再aria2下载完文件后将文件转移到其它目录的自动处理脚本;

脚本来自 shanhe.me 博客:http://shanhe.me/2015/07/07/moving-completed-downloads-to-a-different-directory-in-aria2

编辑aria2.conf文件,增加以下代码

#我添加在配置文件最后一行
on-download-complete=/root/.aria2/move.sh

move.sh脚本内容如下

#!/bin/sh
 
# $1 is gid.
# $2 is the number of files.
# $3 is the path of the first file.
 
DOWNLOAD=/tmp # aria2的下载目录
COMPLETE=/home/down # 你要设置的转移目录路径
LOG=/root/.aria2/mvcompleted.log  #脚本操作日志
SRC=$3
 
if [ "$2" == "0" ]; then
  echo `date` "INFO  no file to move for" "$1". >> "$LOG"
  exit 0
fi
 
while true; do
  DIR=`dirname "$SRC"`
  if [ "$DIR" == "$DOWNLOAD" ]; then
    echo `date` "INFO " "$3" moved as "$SRC". >> "$LOG"
    mv --backup=t "$SRC" "$COMPLETE" >> "$LOG" 2>&1
    exit $?
  elif [ "$DIR" == "/" -o "$DIR" == "." ]; then
    echo `date` ERROR "$3" not under "$DOWNLOAD". >> "$LOG"
    exit 1
  else
    SRC=$DIR
  fi
done
本文地址:https://www.5yun.org/17758.html
关注我们:请关注一下我们的微信公众号:扫描二维码楚盟网的公众号,公众号:chubin5yun
版权声明:本文为原创文章,版权归 楚盟 所有,欢迎分享本文,转载请保留出处!

发表评论


表情