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.