Creating a folder with a subfolder using SpecialFolder

I’m trying to test for the existence of a folder using SpecialFolder and subfolder and create if it’s not there. Looking at the docs, it looks like this should work, but it’s not. It gets to the code in the Else, pops the messagebox and then no folder is created. What am I missing here?

var doc as FolderItem
doc=SpecialFolder.Documents.child("MyStuff").Child("data")
if doc.exists = true then
  MessageBox("Folder Exists")
else
  MessageBox("Creating Folder")
  doc.CreateFolder()
end if

You need to create the folders one at a time

var doc as FolderItem
doc=SpecialFolder.Documents.child("MyStuff")
if doc.exists = true then
  MessageBox("Folder Exists")
else
  MessageBox("Creating Folder")
  doc.CreateFolder()
  doc = doc.Child("data")
  doc.CreateFolder()
end if
1 Like

Thanks. I was thinking that after I posted this :slight_smile: