How do I return a folderitem from NSAppleScriptMBS?

I’ve got one remaining use of AbsolutePath that I need to get rid of. Unfortunately, this is due to an AppleScript:

dim theScript(-1) as String theScript.append "set AccountDirectories to {}" theScript.append "tell application id 'com.apple.mail'" if doEnabledOnly and CarbonModule.SystemVersionAsInt < 101500 then theScript.append "set theAccounts to (get name of accounts whose enabled is true)" else theScript.append "set theAccounts to (get name of accounts)" end if theScript.append "repeat with currentAccount in theAccounts" theScript.append "set the end of AccountDirectories to {account directory of account currentAccount as string}" theScript.append "end repeat" theScript.append "return AccountDirectories" theScript.append "end tell"

This returns a string which is an AbsolutePath. Can I directly get a folderitem as result? I already had a look at item.fileURLValue but this available for non-files , too.

Is it this?

f = FolderItem.Constructor("Test Path", FolderItem.PathTypeNative)

from

FolderItem.Constructor(path as String, pathMode as FolderItem.PathModes, followAlias as Boolean = true)

You can pass posix/native path to AppleScript and use it there.

@David Cox: the returned path is an AbsolutePath and not a NativePath.

@Christian Schmitz: I want to get the folderitems out and not in.

Here is a typical result:

{{“Macintosh HD:Users:beatrixwillius:Library:Mail:V7:18EA0B79-2DA3-44E4-8D24-346258E3EE24:”}, {“Macintosh HD:Users:beatrixwillius:Library:Mail:V7:77BA2C96-A2BD-4C49-B198-CB3F88AAD5A1:”}, {“Macintosh HD:Users:beatrixwillius:Library:Mail:V7:55C8D276-10A3-49C7-B433-12D38454A513:”}, {“Macintosh HD:Users:beatrixwillius:Library:Mail:V7:5927573B-B2F4-4E60-86B4-6CDE390FA496:”}, {“Macintosh HD:Users:beatrixwillius:Library:Mail:V7:95A3F8C7-BA1F-4CBA-B250-416EC2F112C5:”}, {“Macintosh HD:Users:beatrixwillius:Library:Mail:V7:B58A2E27-1E22-4FA3-8630-034C593E3CBA:”}, {“Macintosh HD:Users:beatrixwillius:Library:Mail:V7:D12BEE86-4B97-4D57-9841-8F9D4C057E7D:”}}

I don’t want to fiddle with FolderItems because the path is mostly prohibited even with full disk access.

I think you can return the POSIX paths from your applescript.
As far as I remember, you can convert them like this:

set thePOSIXPath to (the POSIX path of theHFSPath)