我使用以下代码在目录中找到最早的文件:
find /Volumes/Hams\ Hall\ Workspace/Tabletop\ 7_WIP -type f ! -name '.DS_Store' ! -name '.uid' ! -name 'Thumbs.db' \( ! -regex '.*/\..*' \) -print0 | xargs -0 ls -lUr | head -n 1 >> ~/Desktop/test.csv
大多数时候都可以使用。虽然,如果目录为空并具有自定义图标,则它将索引该图标,并输出它好像是最旧的文件。但是,如果目录不为空,它将正常运行。
您将如何继续跳过Icon
?或者,如果文件夹为空,则完全跳过它?
我尝试使用以下方法排除它:
! -name 'Icon'
-not -path dir
-type d \( ! -name dir \)
-mindepth 1 -maxdepth 1
试图找出同时是file
和directory
的Icon是-f
还是-d
。两者都输出图标不存在。 Icon
仍然显示在日志中。
if [[ -f /Volumes/Hams\ Hall\ Workspace/Tabletop\ 7_WIP/Icon ]]
then
echo the file exists > ~/Desktop/xxx.csv
else
echo the file does not exist >> ~/Desktop/xxx.csv
fi
要么我在某个语法错误的地方徘徊,要么在find
之后出现了问题,因为以上都不起作用。
任何帮助将不胜感激。