Open jacoblyw opened 10 years ago
@jacoblyw
Wow, what's weird. I ran multiple tests before I even thought about using this with delete and I never ran into an issue where mdfind returned things that weren't tagged. On the contrary, it was surprisingly consistent/accurate.
For instance, I literally just ran these commands in sequence:
Last login: Tue Sep 30 13:58:56 on ttys000
You have new mail.
scott@Scotts-MacBook-Pro~/Sites/vagrant-local$ mdfind "tag:2 Day"
scott@Scotts-MacBook-Pro~/Sites/vagrant-local$ mdfind "tag:2 Days"
scott@Scotts-MacBook-Pro~/Sites/vagrant-local$ mdfind "tag:1 Day"
At this point, I moved a picture to the Desktop and tagged it with "1 Day"-
scott@Scotts-MacBook-Pro~/Sites/vagrant-local$ mdfind "tag:1 Day"
/Users/scott/Desktop/Benghazi_03.jpg
scott@Scotts-MacBook-Pro~/Sites/vagrant-local$ mdfind "tag:2 Day"
scott@Scotts-MacBook-Pro~/Sites/vagrant-local$ mdfind "tag:2 Days"
Can you tell me what version of OS X you're running?
@jacoblyw Also, if you are successfully moving files to the trash, why not put in a PR with your changes?
Any reason not to close this issue at this point?
Hello,
I modified your script to move files to the trash (instead of deleting them directly) to make sure it behaved as expected.
I then tagged 3 files with "1 Minute". Imagine my surprise when 13 files appeared in my trash after the first run of os-x-self-destruct.
The problem seems to lie with the query mdfind "tag:$1"
mdfind "tag:1 Minute" catches some files, mdfind "tag:1 Day" others, and so on...
NONE of my files have any of the following tags: 1 Minute, 1 Hour, 1 Day, 1 Week, 1 Month, 1 Year
This may be an undocumented bug or "feature" within Spotlight as the query mdfind "tag:2 Day" also finds a bunch of files with no tags set.
I've changed the query to mdfind "kMDItemUserTags == '$1'" and also the tags to avoid any possibility of confusion ("1 Minute" to "DeleteIn1Minute", etc.)