zoukankan      html  css  js  c++  java
  • 删除指定目录下的过期文件

    测试时,需要自动删除录制的文件,于是写了个脚本,自动删除过期的文件。

    如下:

     1 #!/bin/bash
    2 #待删除目录,根路径
    3 root_path="/figure/Record"
    4
    5 #保存时间:分钟
    6 save_time=1
    7
    8 for source_type in $(ls ${root_path})
    9 do
    10 if test -d ${root_path}/${source_type};then #录制对象目录
    11 cd ${root_path}/${source_type}
    12
    13 for channels in $(ls -b ${root_path}/${source_type}) #通道目录
    14 do
    15 if test -d ${channels};then
    16 cd ${channels}
    17
    18 for dates in $(ls ${root_path}/${source_type}/${channels}) #日期目录
    19 do
    20 if test -d ${dates};then
    21 cd ${root_path}/${source_type}/${channels}/${dates}
    22 find ${root_path}/${source_type}/${channels}/${dates} -type f -mmin ${save_time} -exec rm -fv '{}' \;
    23 fi
    24 done
    25 fi
    26 done
    27 else
    28 echo XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    29 fi
    30 done


     

  • 相关阅读:
    Flutter 导航栏上添加搜索按钮
    tabController保活
    nav 选项卡
    flutter 毛玻璃
    [题解]CodeForces878 D
    [题解]CodeForces878C Tournament
    [题解]NOIP2012
    bzoj1070题解
    bzoj1061题解
    bzoj1059题解
  • 原文地址:https://www.cnblogs.com/chutianyao/p/2387967.html
Copyright © 2011-2022 走看看