Create multiple folders with different names

In my work, I have to create multiple folders (like up to 50) each with a different name.


I saw videos on how this can be done on Excel. I searched online and visited many sites but I couldn't any solution on how this can be done on Mac (and I have a MacBook Air and really want to optimise it).


Would be really, really happy if someone can point me to the right direction! Thanks!

Posted on Jun 8, 2020 8:25 AM

Reply
Question marked as Top-ranking reply

Posted on Jun 9, 2020 4:56 AM

Hello, Doris!


Here you are:


set documentsFolder to (path to home folder as text) & "Documents"


tell application "Finder"
	
	activate
	
	set foldersPath to choose folder with prompt "Choose a destination folder:" default location alias documentsFolder
	
	set folderNameTemplateDialog to display dialog "Input a folder name template:" default answer "AirGraph"
	set folderNumberDialog to display dialog "Input a number of folders:" default answer "1"
	
	set folderNameTemplate to text returned of folderNameTemplateDialog
	set folderNumber to text returned of folderNumberDialog as integer
	
	repeat with counter from 1 to folderNumber
		
		set folderIndex to counter as text
		set folderName to folderNameTemplate & "-" & folderIndex
		
		make new folder at foldersPath with properties {name:folderName}
		
		set counter to (counter + 1)
		
	end repeat
	
end tell


This script will create folders like "nameTemplate-Index" in selected destination. You may choose a folder where your folders to create, folder name template and number of creating folders.


Copy this script and paste it in Script Editor. Press play button and enjoy… ;-)


9 replies
Question marked as Top-ranking reply

Jun 9, 2020 4:56 AM in response to doris170

Hello, Doris!


Here you are:


set documentsFolder to (path to home folder as text) & "Documents"


tell application "Finder"
	
	activate
	
	set foldersPath to choose folder with prompt "Choose a destination folder:" default location alias documentsFolder
	
	set folderNameTemplateDialog to display dialog "Input a folder name template:" default answer "AirGraph"
	set folderNumberDialog to display dialog "Input a number of folders:" default answer "1"
	
	set folderNameTemplate to text returned of folderNameTemplateDialog
	set folderNumber to text returned of folderNumberDialog as integer
	
	repeat with counter from 1 to folderNumber
		
		set folderIndex to counter as text
		set folderName to folderNameTemplate & "-" & folderIndex
		
		make new folder at foldersPath with properties {name:folderName}
		
		set counter to (counter + 1)
		
	end repeat
	
end tell


This script will create folders like "nameTemplate-Index" in selected destination. You may choose a folder where your folders to create, folder name template and number of creating folders.


Copy this script and paste it in Script Editor. Press play button and enjoy… ;-)


Jun 8, 2020 5:41 PM in response to doris170

Hi hi there, I think maybe I did not explain myself clearly.

So I have more than 50 unique names and numbers on Word doc and Numbers (and this is recurring week after week).

And each of them I have to create a folder with their unique name and number.


Any possible way to go about automating that please?


I also have 3 other pdf that I have to insert these names and numbers on.

Anyway to automate that too?


Thanks heaps!!!

Jun 10, 2020 7:17 AM in response to Community User

Hi AirGraph,

Thanks! I tried and realised that I must first have the folders ready before I can do the above. So I think it is not what I am looking for.


Actually all my unique names and numbers are collected in Numbers (app in Mac). and previously in Excel sheet

The thing is now to pull out these numbers and name and name a folder after them.


e.g. Folder 1 Folder 2 Folder3 etc for next 50 folders

Alpha_217 Beta_589 Charlie_898


Not sure if you know what I mean but I think at this point in time, I tried the script you shared and I can't work it out yet.

Still I wanna say thank you for your time! and if you could help me further, that will be fantastic!!

Jun 10, 2020 1:50 AM in response to doris170

doris170 wrote:

Hi AirGraph,
Totally stunned by your generosity!


Hi, Doris!

You are welcome. ;-) This is not difficult for anyone who is familiar with Apple Script programming.


I have not tried this out yet but I will.
I think I may need more than than other to do this cos it'll be like an experiment to me.


Nothing special. Just copy script text, start Script Editor (Application -> Utilities), paste script into and press "Play".


Thanks once again and I will return and give you news on my side :)


OK. Will edit if something goes wrong.


Cheers!


Good luck! ;-)


Jun 10, 2020 7:42 AM in response to doris170

I see. This is more complex task – to create 50 folders, each with unique name, taken from Numbers table cells.

Another words, we should open some input file, read 50 values to name list and create 50 folders according to name list?


If YES, question is – can you export from Numbers these unique names to text file with one name on each string? Something like this:


Alpha_217

Beta_589

Charlie_898


Answer my question, please, and I will think about this task.

Sorry for my runglish (russian english on our slang), cause I study english here, not only answer a questions… ;-)


Jun 8, 2020 5:17 PM in response to Community User

Dear AirGraph,


Thanks and I really appreciate your help and both comments and link for learning.

I am not familiar with programming or Script at all.

I was hoping for a much 'common man' way to do this without going to Script or programming.


https://support.apple.com/guide/automator/welcome/mac

I read through and will have to take time to figure out how to make the different names on all my folders.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Create multiple folders with different names

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.