• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: tags manipulation
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: tags manipulation


  • Subject: Re: tags manipulation
  • From: Shane Stanley <email@hidden>
  • Date: Mon, 28 Sep 2015 15:03:53 +1000

On 28 Sep 2015, at 2:15 PM, Christopher Stone <email@hidden> wrote:

None of this makes me very happy with the current "state-of-the-art".

In my opinion one of the very most important functions of a computer is easily, quickly, and accurately finding things.

To be fair, the problems are largely related to the changes involved in implementing tags. I mean, it's good that the Finder treats tags and labels identically, but it would be quite wrong for mdfind or even tag to ignore what you ask for and look for something more in the Spotlight data. 

Anyway, this uses much the same method as tag -m Red -d (and will similarly take a while) -- I'd be curious what number it returns there.

use scripting additions
use framework "Foundation"

my filesIn:(POSIX path of (path to home folder)) withTag:"Yellow"
on filesIn:posixPath withTag:theTag
set theURL to current application's class "NSURL"'s fileURLWithPath:posixPath
set fileManager to current application's NSFileManager's defaultManager()
set thePaths to current application's NSMutableArray's array()
set theEnumerator to fileManager's enumeratorAtURL:theURL includingPropertiesForKeys:{current application's NSURLTagNamesKey} options:((current application's NSDirectoryEnumerationSkipsPackageDescendants) + (current application's NSDirectoryEnumerationSkipsHiddenFiles as integer)) errorHandler:(missing value)
repeat
set aURL to theEnumerator's nextObject()
if aURL is missing value then exit repeat
set {theResult, theTags} to aURL's getResourceValue:(reference) forKey:(current application's NSURLTagNamesKey) |error|:(missing value)
if theResult as boolean and theTags is not missing value and (theTags's containsObject:theTag) then
thePaths's addObject:(aURL's |path|())
end if
end repeat
thePaths's sortUsingSelector:"localizedStandardCompare:"
return thePaths as list
end filesIn:withTag:

-- 
Shane Stanley <email@hidden>
<www.macosxautomation.com/applescript/apps/>

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: tags manipulation
      • From: Michael Grant <email@hidden>
    • Re: tags manipulation
      • From: Christopher Stone <email@hidden>
References: 
 >tags manipulation (From: Jean-Christophe Helary <email@hidden>)
 >Re: tags manipulation (From: Shane Stanley <email@hidden>)
 >Re: tags manipulation (From: Christopher Stone <email@hidden>)
 >Re: tags manipulation (From: Shane Stanley <email@hidden>)
 >Re: tags manipulation (From: Christopher Stone <email@hidden>)
 >Re: tags manipulation (From: Shane Stanley <email@hidden>)
 >Re: tags manipulation (From: Shane Stanley <email@hidden>)
 >Re: tags manipulation (From: Shane Stanley <email@hidden>)
 >Re: tags manipulation (From: Christopher Stone <email@hidden>)

  • Prev by Date: Re: Another darn problem that's beyond me.
  • Next by Date: Re: tags manipulation
  • Previous by thread: Re: tags manipulation
  • Next by thread: Re: tags manipulation
  • Index(es):
    • Date
    • Thread