• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Labels and tags ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Labels and tags ?


  • Subject: Re: Labels and tags ?
  • From: Shane Stanley <email@hidden>
  • Date: Sat, 24 Jan 2015 22:52:08 +1100

On 24 Jan 2015, at 10:14 pm, Shane Stanley <email@hidden> wrote:

tell application "Finder"
set project_folders to (make folder at project_location with properties {name:project_name}) as alias
end tell

Mind you, there's no reason to bother the Finder at all:

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"
set folderPath to (project_location as text) & project_name
my makeFolderAt:(POSIX path of folderPath)
my setTags:{"courant"} forPath:(POSIX path of folderPath)

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:

on makeFolderAt:posixPath
set theNSFileManager to current application's NSFileManager's defaultManager() -- get the file manager
set {theResult, theError} to theNSFileManager's createDirectoryAtPath:posixPath withIntermediateDirectories:true attributes:(missing value) |error|:(reference)
if theResult as boolean is false then -- happens if there was an error
error (theError's localizedDescription() as text) -- throw an error with the description
end if
end makeFolderAt:

One of the advantages of making folders this way is that it can create any intermediary folders required.

-- 
Shane Stanley <email@hidden>
<www.macosxautomation.com/applescript/apps/>

 _______________________________________________
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: 
 >Labels and tags ? (From: Jean-Christophe Helary <email@hidden>)
 >Re: Labels and tags ? (From: Shane Stanley <email@hidden>)
 >Re: Labels and tags ? (From: Jean-Christophe Helary <email@hidden>)
 >Re: Labels and tags ? (From: Shane Stanley <email@hidden>)

  • Prev by Date: Re: Labels and tags ?
  • Next by Date: "first element whose" in Javascript for Automation
  • Previous by thread: Re: Labels and tags ?
  • Next by thread: Re: Labels and tags ?
  • Index(es):
    • Date
    • Thread