In the macOS terminal, “ls | mdls” commands are on

2019-06-09 12:56发布

问题:

I would like a list of all the date added metadata for my Downloads folder on macOS. I found the following code (for macOS terminal) from http://forums.ilounge.com/applescripts-itunes-mac/100189-mdls-command-tiger.html, but it only works for the home directory. Adding a different directory as a modifier doesn't work, and using cd doesn't work. When I do those things, it still returns the results of the home directory. How do I get it to work for my Downloads folder, or is there another approach I should take? I've dabbled in AppleScript also if that is superior.

ls | mdls -name kMDItemDateAdded *

There is a similar question at Recursive file list of all files, list containing path+name, type, size, creation data, modification date, but I am not knowledgable enough to see if I can adapt it to my purposes.

回答1:

The following lists all dates:

mdls -name kMDItemDateAdded ~/Downloads/*