create folders from list

a recent digital publishing workflow required the creation of over 90 folders (one for each chapter of the book) and each of these also had to include a ‘links’ folder. imagine trying to do that manually — over 90 folders.

applescript droplet icon this is a perfect job for an applescript droplet — drop a text file on the app and watch the folders appear — as if by magic :

screen grab of finder before and after text file is dropped on droplet

this workflow starts with a comma delimited list of folder names. you could also use a tab delimited list. note: this version of the script does not handle returns (line breaks) in the list. the demo list looks like this :

screen grab of comma delimited list

you can get a copy of the CreateFolders app here

screen grab of create folders script compiled in script editor

for those interested in this sort of thing…
this script shows one way to strip leading and trailing spaces from chunks of text. it uses two repeat while loops, each of which keep repeating for as long as the associated statement is true. the repeat loop ceases as soon as the statement is false, and the script moves on.

you could use the repeat until form instead :
repeat until mgThisItem does not start with ” ”

the last part of the script shows a simple, pure applescript way to create folders in the finder. the syntax is tortured and long-winded, but it works a treat. to learn how to create folders and folder hierarchies by scripting the shell, see nigel garvey’s excellent explanation at macscripter

update : if you are in the german or dutch regions you may find that your CSV files export as semi-colon separated (rather than comma separated). in which case you would replace this line :

    set text item delimiters of AppleScript to ","

with this :

    set text item delimiters of AppleScript to ";"

macgrunt icon

Advertisements

17 thoughts on “create folders from list

  1. G’Day Macgrunt,
    I work with a huge Classical music collection and would like to create folders with all the classical composers in order to place my digital files. Your gem will be very handy. Thanks in advance. Cheers

  2. Hello Macgrunt,
    Wow….. i just did find your great work on this website!
    A Mac-addict since 1990, starting with a Classic1 with 9inch dislplay, end moved up to the Imac.
    Always searching for interesting stuff for trying on my dailly work at Prepress.

    I would love to try some of your project scripts like the one above……

    Kind Regards

  3. Every so often one thinks – I wish I could do this voting repetitive task in an elegant way – looks like “create folders from list” will do this. I shoot concerts and need to quickly create a list of folders for the performer lists – do it using cut and paste. Want any images for you or you kids? email me phatfotos.co.uk

    • G’day Tim
      More elegance, less repetition — it’s what it’s all about.
      What a great library you’ve got. I might hit you up later in the year if one of the kids ends up doing another carnival project.
      Flicking that app to you now.
      Have a good one.
      m.

  4. If possible I would like the CreateFolders.scpt to create folders from lists of items to be sorted on the Mac. Thanks.

  5. Hey Macgrunt! I loved this post!! So useful!!! Thanks for sharing this!!!
    Do you think it’s possible make one that would work with a .csv? for subfolders as well?

thoughtful and respectful comments welcome

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s