查找某个时间点范围内改动的文件
文件 时间 查找 某个 范围 改动
2023-09-11 14:21:01 时间
常常因为磁盘空间不足的原因,须要删除旧文件,因此希望有一个函数,可以查找到某个时间点之前的文件,并删除之。
用newLISP来实现的话,须要相似这种功能:
(define (location-file-based-on-modified-time dir-path from-seconds to-seconds file-op) (unless (directory? dir-path) (throw-error (string dir-path " folder does not exist")) ) (set 'dir-path (make-sure-folder-path-end-of-slash dir-path)) (recursive-access-dir dir-path file-op (list from-seconds to-seconds)))
调用代码:
;; @[from-seconds, to-seconds) (define (show-file file-path ext-context) (set 'm-time ((file-info file-path) 6)) (set 'from (ext-context 0)) (set 'to (ext-context 1)) (unless (and (>= m-time from) (< m-time to)) (if (regex ".txt$" file-path) (begin (println "---begin---") (println file-path) (println (string "modified time: " (date m-time))) (println (string "from time: " (date from))) (println (string "to time: " (date to))) (delete-file file-path) (println (sys-error)) (println "---end---"))) )) (set 'cur-time (date-value)) (set 'five-hours-ago (- cur-time (* 3600 5))) ;;(println cur-time) ;;(println five-hours-ago) (catch (FILE:location-file-based-on-modified-time "/tmp" five-hours-ago cur-time show-file) 'result) (if result (println result))
假设找到,则返回true, 否则返回nil.
相关文章
- git 忽略文件的四种方式
- 修改后的小米文件管理器(去掉远程管理)
- 多线程取读文件(别人的,有点晕,先放在这里有时间研究研究)
- php/nginx/axios: 文件上传: 配置最长执行时间等相关项 (php8.1.1 / nginx 1.18.0 / vue@3.2.26 )
- 用虚拟鸭子CYBERDUCK同步RACKSPACE CLOUD文件
- 获取下载文件的大小
- python处理文件、文件夹-小结
- Linux的文件时间属性:atime、ctime、mtime
- php/nginx/axios: 文件上传: 配置最长执行时间等相关项 (php8.1.1 / nginx 1.18.0 / vue@3.2.26 )
- MFC Windows 程序设计[274]之文件下拉框例程(附源码)
- DL:基于keras和tensorflow 框架保存网络结构/网络拓扑图/网络模型(json、yaml、h5等文件)注意事项及代码实现(保存和加载.h5模型文件案例)之详细攻略
- Android 文件按时间,大小,修改日期,类型的排序
- python 判断文件的创建时间和当前时间的比较
- 【Android Gradle 插件】将自定义 Gradle 插件上传到自建 Maven 仓库 ④ ( 默认生成的 pom 文件 | Maven 中的 pom 配置 | 自定义 pom 文件节点 )
- python getctime() 文件最后一次的改变时间
- Linux文件时间属性
- grep文件搜索内容
- linux命令之stat,查看文件的三个时间属性
- 需要获取trustedinstaller权限才能删除文件,删不了
- ceph InfoLocker WORM时钟 WORM属性 WORM日志 WORM 计算文件过期时间 WORM文件状态
- 通过jxl 读取excel 文件中的日期,并计算时间间隔
- GitHub怎么创建仓库上传文件
- 文件操作(c++)
- 【看表情包学Linux】Redirect 重定向 | 时间相关指令 | 文件查找 | 打包与压缩
- 文件及目录实际案例