Applescript: Create new Folder and subfolder

I want to create a new Folder with any subfolders with applescript.
How can i do this?
How must the script look like?
Thanks, Alex

for example,


tell application "DEVONthink Pro"
	create record with {name:"gwbush", type:group} in current group
end tell

would create a folder/group with the indicated name in the current group. Or did I misunderstand what you’re asking? (I am in fact answering the following question: “how can I create a group in any subfolder”).

Hey, thanks a lot!

I want to make one mainfolder with any subfolders in it like this:

-Mainfolder
–Sub1
–Sub2
– --SubSub1
– -- SubSub2

I want to name the mainfolder in a prompt.

But with your script i can now continue to write the script.
Thanks al lot!

I appreciate that this is an old post, but I ended up here looking for the solution, so when I finally solved it I thought I would post back - I hope it is useful to some if not @cuborg :slight_smile:

I wanted to create a group with a list of countries and create several sub-folders in the newly created folder.

This is how I solved it,

tell application "DEVONthink 3"
	set listOfGroups to {"Albania", "Slovenia", "Slovak Republic", "Singapore", "Seychelles", "Saudi Arabia", "San Marino", "Samoa", "Saint Vincent and the Grenadines", "SaintLucia", "Russia", "Romania", "Portugal", "Poland", "Pakistan", "Norway", "New Zealand", "Netherlands", "Nauru", "Montserrat", "Mexico", "Mauritius", "Marshall Islands", "Malta", "Malaysia", "Macao", "Luxembourg", "Lithuania", "Liechtenstein", "Lebanon", "Latvia", "Kuwait", "Korea", "Jersey", "Japan", "Italy", "Israel", "Isle of Man", "Ireland", "Indonesia", "India", "Iceland", "Hungary", "Hong Kong", "Guernsey", "Greenland", "Greece", "Gibraltar", "Germany", "Georgia", "Finland", "Faroe islands", "Estonia", "Ecuador", "Denmark", "Czechoslovakia", "Cyprus", "Curacao", "Croatia", "Cook Islands", "Costa Rica", "Colombia", "China", "Chile", "Cayman Islands", "Canada", "Bulgaria", "Brunei darussalam", "Brazil", "Bermuda", "Belgium", "Bahrain", "Bahamas", "Azerbaijan", "Austria", "Australia", "Aruba", "Argentina", "Andorra"}
	repeat with CurrentItem in listOfGroups
		set NewGroup to create record with {name:CurrentItem & " Information", type:group} in current group
		create record with {name:"Holiday Homes", type:group} in NewGroup
		create record with {name:"Beaches", type:group} in NewGroup
		create record with {name:"Places to Visit", type:group} in NewGroup
	end repeat
	
end tell

Welcome @wraydc

Thanks for sharing your solution. :slight_smile:

Here’s an alternate solution using two nested repeats and the create location command…

tell application "DEVONthink 3"
	set listOfGroups to {"Albania", "Slovenia", "Slovak Republic", "Singapore", "Seychelles", "Saudi Arabia", "San Marino", "Samoa", "Saint Vincent and the Grenadines", "SaintLucia", "Russia", "Romania", "Portugal", "Poland", "Pakistan", "Norway", "New Zealand", "Netherlands", "Nauru", "Montserrat", "Mexico", "Mauritius", "Marshall Islands", "Malta", "Malaysia", "Macao", "Luxembourg", "Lithuania", "Liechtenstein", "Lebanon", "Latvia", "Kuwait", "Korea", "Jersey", "Japan", "Italy", "Israel", "Isle of Man", "Ireland", "Indonesia", "India", "Iceland", "Hungary", "Hong Kong", "Guernsey", "Greenland", "Greece", "Gibraltar", "Germany", "Georgia", "Finland", "Faroe islands", "Estonia", "Ecuador", "Denmark", "Czechoslovakia", "Cyprus", "Curacao", "Croatia", "Cook Islands", "Costa Rica", "Colombia", "China", "Chile", "Cayman Islands", "Canada", "Bulgaria", "Brunei darussalam", "Brazil", "Bermuda", "Belgium", "Bahrain", "Bahamas", "Azerbaijan", "Austria", "Australia", "Aruba", "Argentina", "Andorra"}
	set listOfSubgroups to {"Holiday Homes", "Beaches", "Places to Visit"} -- Set up the subgroups
	
	repeat with CurrentItem in listOfGroups -- Repeat with the country
		repeat with subGroup in listOfSubgroups -- Repeat with the subgroup
			create location ("/Inbox/Countries/" & CurrentItem & " Information/" & subGroup) in current database
		end repeat
	end repeat
end tell

And the result, noting I’ve sequestered these in a Countries folder in the database’s Inbox for my testing…

Nice enhancement @BLUEFROG thank you :grinning:

My pleasure :slight_smile: