I use below code to find the oldest file in the directory:
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
It works most of the time. Although, if directory is empty and has custom Icon, it indexes the Icon, and outputs as if it is the oldest file. Although, if the directory is not empty, it will work as normal.
How would you go on skipping the
Icon ? Or if the folder is empty, simply skip it entirely?
I've tried excluding it with:
! -name 'Icon'
-not -path dir
-type d \( ! -name dir \)
-mindepth 1 -maxdepth 1
Tried to find out if Icon is
-d. Both output that Icon doesn't exist. Yet the
Iconstill shows up in the log.
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
Either I am havig somewhere a syntax error, or something goes wrong after
find, as none of the above worked.
Any help would be much appreciated.