ASObjC call to fileManager's createDirectoryAtPath

This is similar to the post of “Read/Write Files to App’s Bundle in Xcode”, but I am calling right from ASObjC.

I am trying to make a routine I can store in a library. My code is based off of Shane Stanley’s book and is

use framework “Foundation”
use framework “AppKit”
use scripting additions

global theError
set currentFolder to choose folder
set currentPOSIX to POSIX path of currentFolder
set folderName to “createdFolder”

set myResult to my makeFolderAt:currentPOSIX withName:folderName

on makeFolderAt:POSIXPath withName:theName
set fileManager to current application’s NSFileManager’s defaultManager()
set POSIXPath to current application’s NSString’s stringWithString:POSIXPath
set newPath to POSIXPath’s stringByAppendingPathComponent:theName
log newPath as text
set theResult to fileManager’s createDirectoryAtPath:POSIXPath withIntermediateDirectories:true attributes:(missing value) |error|:(missing value)
log theResult as text
–log (theError’s localizedDescription()) as text
–return {(theResult as integer = 1), (theError’s localizedDescription()) as text}
end makeFolderAt:withName:


The code returns (true), but never creates the subdirectory. OS is 10.10.1

Model: MBP 15" retina
Browser: Safari 600.2.5
Operating System: Mac OS X (10.8)

Hi,

you’re going to create the folder POSIXPath (which already exists) instead of newPath

Oh that’s embarrassing.

thank you.