Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with MDfind query #8

Open
jacoblyw opened this issue Sep 30, 2014 · 3 comments
Open

Problem with MDfind query #8

jacoblyw opened this issue Sep 30, 2014 · 3 comments

Comments

@jacoblyw
Copy link

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.)

@tdlm
Copy link
Owner

tdlm commented Oct 1, 2014

@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?

@tdlm
Copy link
Owner

tdlm commented Oct 1, 2014

@jacoblyw Also, if you are successfully moving files to the trash, why not put in a PR with your changes?

@tdlm
Copy link
Owner

tdlm commented Dec 6, 2016

Any reason not to close this issue at this point?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants