ANN: Some routines for Spotlight
Hi Thierry, your code : put unidecode(uniencode(thefilename,"utf8"),"ansi") 1) is very 'slow" since there are somtimes many lines in thefilename 2) is not fully translating the answer. There are further errors with çedilla, "œ",.. any other suggestion ?? Greetings. Yves COPPE [EMAIL PROTECTED] ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: ANN: Some routines for Spotlight
Yves, Andre, I don't have Tiger to test mdfind, but if I understand well the problem, OS X filenames are UTF8 encoded. The following function will convert from UTF8 to ANSI, just replace "thefilename" with the actual string to decode. put unidecode(uniencode(thefilename,"utf8"),"ansi") I hope this helps, Thierry On 2005, Aug 21, , at 21:28, Yves COPPE wrote: Le 21-août-05 à 21:20, Andre Garzia a écrit : Yves, I am trying here with accents and special chars... it appears that mdfind returns a mixed string. Like I have this file called çedilha (which is wrong portuguese, but serves right for our experiments). mdfind will return a string using with the ç encoded in what I think is more than two bytes and the rest of the filename in good plain text. So using uniDecode to reduce from twobytes representation will screw the rest of the filename, using uniEncode to put the rest of the string up to two bytes will also not work for it will re-encode the special chars... I am a little lost too, need more expert help. Andre Hi Andre, I'm happy to see that the problem does exist, non only on my computer. So I'm sure someone on the list will find the correction. Greetings. Yves COPPE [EMAIL PROTECTED] ___ use-revolution mailing list [EMAIL PROTECTED] Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution ___ use-revolution mailing list [EMAIL PROTECTED] Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: ANN: Some routines for Spotlight
Le 21-août-05 à 21:20, Andre Garzia a écrit : Yves, I am trying here with accents and special chars... it appears that mdfind returns a mixed string. Like I have this file called çedilha (which is wrong portuguese, but serves right for our experiments). mdfind will return a string using with the ç encoded in what I think is more than two bytes and the rest of the filename in good plain text. So using uniDecode to reduce from twobytes representation will screw the rest of the filename, using uniEncode to put the rest of the string up to two bytes will also not work for it will re-encode the special chars... I am a little lost too, need more expert help. Andre Hi Andre, I'm happy to see that the problem does exist, non only on my computer. So I'm sure someone on the list will find the correction. Greetings. Yves COPPE [EMAIL PROTECTED] ___ use-revolution mailing list [EMAIL PROTECTED] Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: ANN: Some routines for Spotlight
Le 21-août-05 à 19:53, Andre Garzia a écrit : Folks, Since I started using MacOS X Tiger, I became very fond of Spotlight since it reminds me of BFS. Spotlight has support for very advanced queries using nested boolean logic and cool metadata filters but those features are not exposed in the normal spotlight ui. To access those functions you need to code your query using Objective-C or use command line tools. By the use of shell() command we can harvest most of the spotlight power by calling commandline tools, the spotlight command line tools start with md (from metadata). Hi Andre, I have a little problem with your function. In Mac OS X French you have accent, umlaut, cedilla,... so my script : put mdfind(tSearch) into tmp gives unreadable result so I've tried : put urldecode(tmp) into tmp put isotomac(tmp) into tmp but it stays unreadable when you ask for the detailed fiiles and urldecode the result, then are the lines readable. How can I perform that ? Thank you Greetings. Yves COPPE [EMAIL PROTECTED] ___ use-revolution mailing list [EMAIL PROTECTED] Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: ANN: Some routines for Spotlight
Yves, I am trying here with accents and special chars... it appears that mdfind returns a mixed string. Like I have this file called çedilha (which is wrong portuguese, but serves right for our experiments). mdfind will return a string using with the ç encoded in what I think is more than two bytes and the rest of the filename in good plain text. So using uniDecode to reduce from twobytes representation will screw the rest of the filename, using uniEncode to put the rest of the string up to two bytes will also not work for it will re-encode the special chars... I am a little lost too, need more expert help. Andre On Aug 21, 2005, at 3:58 PM, Yves COPPE wrote: Le 21-août-05 à 19:53, Andre Garzia a écrit : Folks, Since I started using MacOS X Tiger, I became very fond of Spotlight since it reminds me of BFS. Spotlight has support for very advanced queries using nested boolean logic and cool metadata filters but those features are not exposed in the normal spotlight ui. To access those functions you need to code your query using Objective-C or use command line tools. By the use of shell() command we can harvest most of the spotlight power by calling commandline tools, the spotlight command line tools start with md (from metadata). Hi Andre, I have a little problem with your function. In Mac OS X French you have accent, umlaut, cedilla,... so my script : put mdfind(tSearch) into tmp gives unreadable result so I've tried : put urldecode(tmp) into tmp put isotomac(tmp) into tmp but it stays unreadable when you ask for the detailed fiiles and urldecode the result, then are the lines readable. How can I perform that ? Thank you Greetings. Yves COPPE [EMAIL PROTECTED] ___ use-revolution mailing list [EMAIL PROTECTED] Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution ___ use-revolution mailing list [EMAIL PROTECTED] Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
ANN: Some routines for Spotlight
Folks, Since I started using MacOS X Tiger, I became very fond of Spotlight since it reminds me of BFS. Spotlight has support for very advanced queries using nested boolean logic and cool metadata filters but those features are not exposed in the normal spotlight ui. To access those functions you need to code your query using Objective-C or use command line tools. By the use of shell() command we can harvest most of the spotlight power by calling commandline tools, the spotlight command line tools start with md (from metadata). More can be learned from the Ars Technica Tiger review at: http:// arstechnica.com/reviews/os/macosx-10.4.ars/9 So, I took some time to create some functions that we can use to harvest those powers and they are below: function mdfind pQuery -- This one find matching files based on a given query. return shell("mdfind" && pQuery) end mdfind function mdls pQuery -- Returns a chunk with all Metadata info for a given file. return shell("mdls" && pQuery) end mdls function MetadataToArray pQuery -- Takes the metadata chunk and turns it into an Array. -- This is easier to access than the chunk. -- There are some extra steps to erase extra spaces. local tTempA, tReturnValA put mdls(pQuery) into tTempA split tTempA by cr and "=" repeat for each line tKey in the keys of tTempA get offset(" ", tKey) get char 1 to (it - 1) of tKey put tTempA[tKey] into tReturnValA[it] end repeat return tReturnValA end MetadataToArray function mdimport pFile -- forces reindexing on a given file, use it after you change its metadata. -- we all know that the kernel hooks should make this useless but... return shell("mdimport" && pFile) end mdimport Have fun friends andre ___ use-revolution mailing list [EMAIL PROTECTED] Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution