Shell:执行“查找”时不索引文件夹图标/跳过空文件夹

时间:2019-04-30 09:55:14

标签: macos shell csv find

我使用以下代码在目录中找到最早的文件:

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?或者,如果文件夹为空,则完全跳过它?

我尝试使用以下方法排除它:

  1. ! -name 'Icon'
  2. -not -path dir
  3. -type d \( ! -name dir \)
  4. -mindepth 1 -maxdepth 1
  5. 试图找出同时是filedirectory的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之后出现了问题,因为以上都不起作用。

enter image description here

任何帮助将不胜感激。

0 个答案:

没有答案