Welcome to NeoOffice developer notes and announcements
NeoOffice
Developer notes and announcements
 
 

This website is an archive and is no longer active
NeoOffice announcements have moved to the NeoOffice News website


Support
· Forums
· NeoOffice Support
· NeoWiki


Announcements
· Twitter @NeoOffice


Downloads
· Download NeoOffice


  
NeoOffice :: View topic - applescript help, or why i was almost a genius
applescript help, or why i was almost a genius
 
   NeoOffice Forum Index -> Random Whatnot
View previous topic :: View next topic  
Author Message
jakeOSX
Ninja
Ninja


Joined: Aug 12, 2003
Posts: 1373

PostPosted: Fri Jan 21, 2005 11:01 am    Post subject: applescript help, or why i was almost a genius

ok. so i did a search one day for all of my neo-docs straight from the finder. it was great, there in that folder was everything (even docs with the same name)

so i got to thinking about folder actions and the light bulb went on. i should be able to make a folder that does that automatcially when i start it. i started reading up on applescript, and folder actions. wrote some code, which didn't work.

here is the thing, i can't figure out how to call the finder's search function, or if i can't, how to search the hdd for files and list them in the folder.

anyone have thoughts?
Back to top
Max_Barel
Oracle


Joined: May 31, 2003
Posts: 219
Location: French Alps

PostPosted: Fri Jan 21, 2005 1:32 pm    Post subject: system events

Did you try to use the "system events" dictionnary?

This might allow you to simulate any UI action, so hopefully a finder seach.

Max
Back to top
Terry Teague
Guest





PostPosted: Sat Jan 22, 2005 2:41 am    Post subject: Re: applescript help, or why i was almost a genius

jakeOSX wrote:
ok. so i did a search one day for all of my neo-docs straight from the finder. it was great, there in that folder was everything (even docs with the same name)

so i got to thinking about folder actions and the light bulb went on. i should be able to make a folder that does that automatcially when i start it. i started reading up on applescript, and folder actions. wrote some code, which didn't work.

here is the thing, i can't figure out how to call the finder's search function, or if i can't, how to search the hdd for files and list them in the folder.

anyone have thoughts?

It is not clear to me exactly which part of this puzzle you need help with.

With folder actions, you need to write script handlers for specific actions that get attached to the folder of interest - these actions can be when the folder's window is opened/closed/moved/resized, and when files are added/deleted to/from the folder. You can do things like launch applications for the items newly added to the folder.

I believe the window associated with the results of a Finder "Find" is NOT a window belonging to a real folder, so even you were able to script "Find", you couldn't attach folder actions to the results "folder".

I don't think "Find" is directly scriptable. You might be able to script Sherlock to do a Internet search of the local "file:///Volumes" URL.

Personally I would just use (assuming for the moment this is for your use on your machine, since it might require the BSD subsystem to be installed, and you would need additional checking in a script that other people may use) the command line "find" tool with the AppleScript "do shell script" command.

e.g.

set list_of_writer_files to do shell script "find / -name \"*.sxw\""

Having found the files, I don't know what you need to do with them - folder action scripts are not really required. You could copy/move the found files, or create aliases/symlinks to the found files, or you could open the found files directly in the application of your choice.

Where it gets tricky, is the conversions between POSIX pathnames ("/Volumes/Mac HD/thisfile"), Mac OS pathnames ("Mac HD:thisfile"), and URLs (file:///Volumes/Mac%20HD/thisfile), needed by the various pieces involved in the solution, dealing with UTF-8 filenames, shell quoting, AppleScript/shell quoting etc.

Mac OS X comes with a complete set of AppleScript examples, including folder actions - suggest you install the Script Menu extra that you can find in the /Applications/AppleScript folder.

Hope this helps.

Regards, Terry
Back to top
sardisson
Town Crier
Town Crier


Joined: Feb 01, 2004
Posts: 4588

PostPosted: Sat Jan 22, 2005 4:23 am    Post subject: Re: applescript help, or why i was almost a genius

Terry Teague wrote:
I believe the window associated with the results of a Finder "Find" is NOT a window belonging to a real folder, so even you were able to script "Find", you couldn't attach folder actions to the results "folder".


It is a real folder, of sorts. If you switch Find to find visible and invisible files, the first result will be .Search Results.... in /private/tmp/ (it finds itself!) You can add it to your sidebar, but I think it's both static and temporary (is killed when you close Find). (When one does finally get to <tt>ls</tt> it, it seems to contain only . and .., not even symlinks to the files it finds/"contains.")

All of this is totally useless but somehow interesting Smile

Isn't something like what you want supposed to be in 10.4? Or do what Terry says. Terry is the AppleScript guru!

jakeOSX wrote:
applescript help, or why i was almost a genius


I feel the same way every time I sit down to do something in AppleScript. Smile I remain in awe of Terry.

Smokey

_________________
"[...] whether the duck drinks hot chocolate or coffee is irrelevant." -- ovvldc and sardisson in the NeoWiki
Back to top
jakeOSX
Ninja
Ninja


Joined: Aug 12, 2003
Posts: 1373

PostPosted: Sun Jan 23, 2005 8:53 am    Post subject: Re: applescript help, or why i was almost a genius

Terry Teague wrote:
I believe the window associated with the results of a Finder "Find" is NOT a window belonging to a real folder, so even you were able to script "Find", you couldn't attach folder actions to the results "folder".


thanks terry, i think that answers the question. basically i wanted a folder action so that when i opened this certain folder it was the same as doing a search for *.sxw.
Back to top
Display posts from previous:   
   NeoOffice Forum Index -> Random Whatnot All times are GMT - 7 Hours
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Powered by phpBB © 2001, 2005 phpBB Group

All logos and trademarks in this site are property of their respective owner. The comments are property of their posters, all the rest © Planamesa Inc.
NeoOffice is a registered trademark of Planamesa Inc. and may not be used without permission.
PHP-Nuke Copyright © 2005 by Francisco Burzi. This is free software, and you may redistribute it under the GPL. PHP-Nuke comes with absolutely no warranty, for details, see the license.