Bash One liner to create output from mdfind sorted descending by date

Hello.

What is worth looking at in this one is the way the sorting options are used to produce the result.

By the way: I learned something else about Spotlight today: I have always found it a pain a certain place to have to reenter all the criterions each and every time I look for a piece of code. Today I opened the ~/Library/Saved Searches in order to look at some .SavedSearch in the PropertyListEditor, which are very handy to have in the Dock on a permanent basis. By accident I double clicked on the saved search in the SavedSearchFolder, and then I could change the original search argument while retaining all the added criterions for the search. :slight_smile: Great labour saver for me, as I didn’t know about this.

I also learned about the benefits of relying on scptd files, as those files show up in quick look when I press space in a Finder window. (To be honest .scpt files with a creator code of “asDB” also do that, but those with ToyS don’t.

grep -v ":"

ensures us that only entries for this year is returned.

grep -v " 0"

removes files which are empty.

 mdfind -onlyin ~/ "kMDItemTextContent == 'list' && kMDItemContentTypeTree == com.apple.applescript.script " |sed 's/\(^.*$\)/\"\1\"/g' |xargs ls -ld |grep ":" |sort   -k7M,7r -k6n,6r |grep -v " 0" | cut -c 56-200,42-54 |sed 's/\// \//'