Tuesday, March 15, 2011

Set StarRating from CLI

Using information found in the article listed in the Comprehensive summary of Mac Metadata hint, I was able to find a way to write metadata from the CLI, making it possible for shell scripts to modify files in a way that is visible to the Finder, and therefor in Smart Folders and other search results.

Using xattr on the CLI you can write arbitrary metadata to files. This is useful for other CLI scripts because you can search for these arbitrary attributes using mdls. However, if you want to set metadata that is easily searchable in applications like Finder, you have to set the values for existing attributes. Looking through the output of mdimport -X, I located the StarRating attribute as a valuable piece of information to set values for. To set this value for a file, issue the following command:

xattr -w "com.apple.metadata:kMDItemStarRating" "10" fi ...

Add to digg Add to Reddit Add to Slashdot Email this Article Add to StumbleUpon

Source: http://feeds.macosxhints.com/click.phdo?i=d8563bff10d66b644430cef44b6cd7bf

new apple news mac refurb store apple stock news macintosh computers apple news conference live feed tech news apple news live iwork family pack

No comments:

Post a Comment