Smart Folder Scripting
Smart Folder Scripting
- Subject: Smart Folder Scripting
- From: Philip Aker <email@hidden>
- Date: Mon, 25 Feb 2008 19:55:33 -0800
On 08-02-25, at 16:04, Brad Lappin wrote:
Tisk, tisk --> Re: (no subject) Speaking kindly, I don't know Applescript. Cobbling together any piece of working code is usually a time-consuming accomplishment. I've been working on an Automator Workflow for myself and someone else that will allow the user to select images in the Finder, enter metadata tags, then upload the images to Flickr. All that is fine. What I'd like to add into the Workflow, presumably with Applescript, is a script that performs the following steps:
1. Ask the user if s/he would like to create a new Smart Folder. 2. If Yes, prompt the user for Smart Folder keywords criteria. 3. Create a new Smart Folder in ~/Pictures with these search criteria: 1) Kind is: Images and 2) Keywords contains: the user-entered text in Step 2. 4. Ask the user to name the new Smart Folder.
Is this possible? Is there another (better?) method to incorporate this into the Automator Workflow instead of with Applescript?
Possibly. Firstly, Smart Folders saved with criteria are just property list files (XML files with their brains removed) which you can examine with any text editor and script with "System Events". So say the keyword from above is "joe", then the top of the property list file looks like:
<?xml version="1.0" encoding="UTF-8"?> <plist version="1.0"> <dict> <key>CompatibleVersion</key> <integer>1</integer> <key>RawQuery</key> <string>(((kMDItemKeywords = "joe*"cdw) && (_kMDItemGroupId = 13))) && (true)</string> <key>RawQueryDict</key> <dict> <key>FinderFilesOnly</key> <true/> <key>RawQuery</key> <string>(((kMDItemKeywords = "joe*"cdw) && (_kMDItemGroupId = 13))) && (true)</string> ...
So I think you might be able to keep a template saved search somewhere, apply an XSLT to it such that the keyword is replaced and then direct the output to ~/Pictures.
Secondly, you can use the command line tool < x-man-page://mdfind> to attain the same query and result much more directly.
Thirdly, you can use MetaData.osax < http://www.vcn.bc.ca/~philip/> (AppleScript translation of mdfind) as an integrated part of any AppleScript to coordinate easily with a dialog presented to the user asking for the keyword.
|
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden
References: | |
| >(no subject) (From: Brad Lappin <email@hidden>) |