Re: Labels and tags ?
Re: Labels and tags ?
- Subject: Re: Labels and tags ?
- From: Shane Stanley <email@hidden>
- Date: Sat, 24 Jan 2015 22:14:59 +1100
On 24 Jan 2015, at 9:43 pm, Jean-Christophe Helary <email@hidden> wrote:
Tangential issue: paths and types (classes ?)...
on setTags:tagList forPath:posixPath
looks like it requires a posix path, but I have no idea what the "project_folders" construct I created is and if I call "posix path of" on it, I get an error:
set project_location to choose folder with prompt "Choose folder:" default location "/Default/path/to/folder"
set project_folders to make folder at project_location with properties {name:project_name}
If you're using "make folder", you're presumably within a Finder tell block, and it will return a Finder reference.
When I insert a "return class of (project_folders)" to check what project_folder is I get "folder" (which by the way is *not* a defined class in the Class Reference chapter of the Applescript Reference...)
That's right; the Finder deals in folders. You need to coerce it to an alias to be able to do anything with it outside a Finder tell block.
And when I use my setTags:"courant" forPath:(POSIX path of project_folders), I get the following error:
error "Can’t make «class cfol» \"folder_name\" of «class cfol» \"folder_name\" of «class cfol» \"Desktop\" of «class cfol» \"suzume\" of «class cfol» \"Users\" of «class sdsk» of application \"Finder\" into the expected type."
Notice the Finder reference in there. Also see that the variable is "tagList", which is a hint that it wants a list of tags.
And since I can't find a reference to that "class sdsk" anywhere I'm a bit lost..
It's "startup disk", but it doesn't matter.
So try this for size:
use scripting additions use framework "Foundation"
set project_name to "My smashing project" set project_location to choose folder with prompt "Choose folder:" --default location "/Default/path/to/folder" tell application "Finder" set project_folders to (make folder at project_location with properties {name:project_name}) as alias end tell my setTags:{"courant"} forPath:(POSIX path of project_folders)
on setTags:tagList forPath:posixPath -- set the tags, replacing any existing tags set aURL to current application's |NSURL|'s fileURLWithPath:posixPath -- make URL aURL's setResourceValue:tagList forKey:(current application's NSURLTagNamesKey) |error|:(missing value) end setTags:forPath:
|
_______________________________________________
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