Go Back   The Apple Blog Community > Apple/Mac > Development
Register Social Groups iSpy Members List Search Today's Posts Mark Forums Read FAQ

Development XCode, Cocoa, and all other development

Reply
 
LinkBack Thread Tools Search this Thread
02-27-2007   #1 (permalink)
Operator
 
Join Date: Dec 2006
Posts: 9
NotVeryPC has disabled reputation
Having just started to use Tags with Quicksilver I'd like to display the Tags I've already used on my desktop with GeekTool.

I've found where Quicksilver stores the Tags and I've got a basic command to get the Tags out of the file but I could do with some help removing the duplicates and extra text.

Here's the code:
Code:
grep string /Users/username/Library/Caches/Quicksilver/Indexes/QSPresetQSFileTagsPlugIn.qsindex | awk {'print $1'}  > /Users/username/Desktop/tags.txt
The result in file looks like this:
<string>guides</string>
<string>guides</string>
<string>qs.tag.file</string>
<string>scripts</string>
<string>scripts</string>
<string>qs.tag.file</string>
<string>Guide</string>
<string>Guide</string>
<string>qs.tag.file</string>

I'd like to remove the <string>qs.tag.file</string> lines and the <string> </string>

Does anyone know how to do this?
NotVeryPC is offline   Reply With Quote
02-27-2007   #2 (permalink)
TAB Author
 
nicks's Avatar
 
Join Date: Oct 2006
Location: Denver, CO
Posts: 114
nicks is on a distinguished road
Send a message via AIM to nicks Send a message via MSN to nicks
I'm gonna hack around with this a little. see if I can [find the time to] brush up on my years-old awk/sed/ scripting... no promises
__________________
Sometimes I write for The Apple Blog. Mostly about Quicksilver.
nicks is offline   Reply With Quote
02-28-2007   #3 (permalink)
Operator
 
Join Date: Dec 2006
Posts: 9
NotVeryPC has disabled reputation
With help from MacScripter.net, here's the finished scritp:

Code:
set QuicksilverTags to (path to home folder as string) & "Library:Caches:Quicksilver:Indexes:QSPresetQSFileTagsPlugIn.qsindex"

do shell script "grep string " & (quoted form of POSIX path of QuicksilverTags) & " | awk {'print $1'}"

set theTags to result

--> From the MacScripter.net Text Delimiters Tutorial.
set newText to switchText of theTags from "<string>qs.tag.file</string>" to ""
to switchText of currentText from SearchString to ReplaceString
	set storedDelimiters to AppleScript's text item delimiters
	set AppleScript's text item delimiters to SearchString
	set currentText to currentText's text items
	set AppleScript's text item delimiters to ReplaceString
	set currentText to currentText as Unicode text
	set AppleScript's text item delimiters to storedDelimiters
	
	currentText
	
	set this_text to currentText
	
	set new_text to ""
	
	--> From the MacScripter Forum.
	repeat with myPara in paragraphs of this_text
		if new_text does not contain myPara then set new_text to new_text & myPara & return
	end repeat
	set new_text to (characters 1 thru -2 of new_text) as text
	
	set more_text to new_text
	set replace_text to ""
	
	--> From MacScripter Forum.
	repeat with myPara in paragraphs of more_text
		
		if replace_text does not contain myPara then set replace_text to replace_text & (text 9 thru -10 of myPara) & return
	end repeat
	
	set output to "Tags: " & return & replace_text
	
end switchText -- the end of the handler.
Just call it from GeekTool.
NotVeryPC is offline   Reply With Quote
03-07-2007   #4 (permalink)
Operator
 
Join Date: Mar 2007
Posts: 1
paynito has disabled reputation
You need to copy the script into "Script Editor" and save it as "GetTags.scpt"

In GeekTool create a new entry with the command
Code:
osascript /Users/username/path/to/script/GetTags.scpt
Hope this helps.

Yes. It does help a lot.
So in 13 point type I can display all my tags. Anyone know how to make that text file or geektool wordwrap or start a second column? Hmm. We didn't even actually create a text file per se.
I think the mac scripter forum mentioned is here.

Last edited by paynito; 03-07-2007 at 09:55 AM. Reason: spelling mistake
paynito is offline   Reply With Quote
03-08-2007   #5 (permalink)
Operator
 
Join Date: Dec 2006
Posts: 9
NotVeryPC has disabled reputation
Quote:
Anyone know how to make that text file or geektool wordwrap or start a second column? Hmm. We didn't even actually create a text file per se.
My original idea was to create a text file and have GeekTool read it but during the course of writing the script I decided to just read the Quicksilver file instead.

As for having GeekTool wordwrap, I don't think that's possible. If you can create a text file with the tags in columns then GeekTool will display that.
NotVeryPC is offline   Reply With Quote
03-20-2007   #6 (permalink)
Operator
 
Join Date: Mar 2007
Posts: 2
DTrate has disabled reputation
This is a great script! I have no knowledge of Applescript whatsoever, yet I have been able to get it to work.

However, it displays my tags as a (seemingly) random list of words -- is there any way to alphabetize it by modifying the script (or otherwise)?
DTrate is offline   Reply With Quote
03-20-2007   #7 (permalink)
Concierge
 
mdmunoz's Avatar
 
Join Date: Nov 2006
Location: Davis, CA
Posts: 643
mdmunoz has disabled reputation
Send a message via AIM to mdmunoz
Quote:
Originally Posted by DTrate View Post
This is a great script! I have no knowledge of Applescript whatsoever, yet I have been able to get it to work.

However, it displays my tags as a (seemingly) random list of words -- is there any way to alphabetize it by modifying the script (or otherwise)?
All you have to do is change
Quote:
do shell script "grep string " & (quoted form of POSIX path of QuicksilverTags) & " | awk {'print $1'}"
To
Quote:
do shell script "grep string " & (quoted form of POSIX path of QuicksilverTags) & " | awk {'print $1'} | sort"
on the second line of code (a sort pipe is added at the very end).

If you want reverse order, use "sort -r" instead of "sort"

Last edited by mdmunoz; 03-20-2007 at 10:27 PM.
mdmunoz is offline   Reply With Quote
03-21-2007   #8 (permalink)
Operator
 
Join Date: Mar 2007
Posts: 2
DTrate has disabled reputation
Excellent! Thanks a lot for the info.

Now if only QS could auto-tag my 'Documents' folder for me.....
DTrate is offline   Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT -6. The time now is 05:42 AM.




Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC5
© 2004-2008