# 无限移动Plot文件脚本

**URL:** <https://www.shiwantech.xyz/t/topic/245>\
**Category:** Chia\
**Created:** [2024 年10 月 13 日 14:15 UTC](https://www.shiwantech.xyz/t/topic/245 "2024-10-13T14:15:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

作者： ![itpanpan163](https://www.shiwantech.xyz/letter_avatar_proxy/v4/letter/i/ccd318/32.png) [@itpanpan163](https://www.shiwantech.xyz/u/itpanpan163)\
发布日期： [2024 年10 月 13 日 14:15 UTC](https://www.shiwantech.xyz/t/topic/245/1 "2024-10-13T14:15:27Z")

</div>

```auto
#!/bin/bash
echo "无限移动Plot文件"
#sleep 15m
countVar=0;
plotCount1=0
fromWhere1="/mnt/1/*.plot"
fromWhere2="/mnt/1/*.plot"
toWhere="/media/wayne/zhang-4/"
while true;
do
  if ls $fromWhere1 >/dev/null 2>&1;then
    plotCount=0
    for file in $fromWhere1
    do
      plotCount=$(($plotCount+1))
    done
    echo "有 $plotCount 个新文件，开始移动" date "+%y-%m-%d %H:%M:%S"
    plotCount=0
    for file in $fromWhere1
    do
    if [-f "$file"]
    then
      plotCount=$(($plotCount+1))
      echo date "+%y-%m-%d %H:%M:%S" "转移第 $plotCount 个 $file"
      mv $file $toWhere
      countVar=$(($countVar+1))
    fi
    done
    echo "结束本轮移动" date "+%y-%m-%d %H:%M:%S"
  elif ls $fromWhere2 >/dev/null 2>&1;
  then
     plotCount1=0
    for file in $fromWhere2
    do
      plotCount1=$(($plotCount1+1))
    done
    echo "次路径囤积数量= $plotCount1 个" date "+%y-%m-%d %H:%M:%S"
    if [$plotCount1 -ge 1]
    then
       echo "次路径囤积数量超过1个，移走超出部分" date "+%y-%m-%d %H:%M:%S"
       countFor=0
       for file in $fromWhere2
         do
         if [-f "$file"]
         then
            countFor=$(($countFor+1))
            if [$countFor -ge 1]
            then
              echo date "+%y-%m-%d %H:%M:%S" "转移次路径的第 $countFor 个 $file"
              mv $file $toWhere
              countVar=$(($countVar+1))
              break
            fi
         fi
        done
    else
       echo "次路径文件太少，先不予移动" date "+%y-%m-%d %H:%M:%S"
       sleep 4s
    fi
  else
    echo "无新文件" date "+%y-%m-%d %H:%M:%S"
    sleep 4s
  fi
  echo "完成总数 count= $countVar" ";" date "+%y-%m-%d %H:%M:%S"
done

```
