【发布时间】:2014-08-11 15:34:37
【问题描述】:
我在文件系统中存储了大量文件,其中一些是 mp4、jpg 和 pdf
我想删除所有文件,除了一些从 mysql 查询中提取的文件。例如 RandomMovie_04.mp4、AwesomeImage.jpg
这是我的文件结构
files/
messages/
images/
45/ --> this is the ID in the DB
46/
articles/
images/
124/
125/
videos/
124/
207/
我不想删除的文件从数据库中提取
我正在使用 PHP (CakePHP) 和 MySQL
试过了,它适用于一个文件,但我找不到用文件列表执行此操作的方法
find * -maxdepth 5 -not -name "RandomMovie_04.mp4" -type f -exec ls "{}" \; > list.txt
这对两个人有效
find * -maxdepth 5 -not -name "RandomMovie_04.mp4" -not -name "AwesomeImage.jpg" -type f -exec ls "{}" \; > list.txt
我必须对所有排除的文件(在 php 脚本中)执行此操作吗?比如 -not -name fileA -not -name fileB -not -name to_the_infinite...
谢谢
对不起,如果我的英语很烂:(
【问题讨论】: