Generating nested folders with terminal

Discussion in 'Mac Programming' started by terrybell, Mar 16, 2009.

  1. macrumors newbie

    Joined:
    Mar 16, 2009
    #1
    I am trying to work out the most efficient way to generate a series of empty nested folders in OS X.

    I figure there must be a terminal command to do this, but I am a bit of a terminal n00b.

    Also what is there a limit of how many nested folders OS X can support?

    Thanks,

    TB
     
  2. macrumors 601

    HiRez

    Joined:
    Jan 6, 2004
    Location:
    Western US
    #2
    If you use the mkdir command with the -p option, it will create intermediate folders. For example mkdir -p ~/temp01/temp02/temp03 will create a temp03 folder inside a temp02 folder inside a temp01 folder inside your home folder.

    EDIT: oops, forgot the flag in my example...fixed.
     
  3. macrumors regular

    Joined:
    Oct 13, 2008
    Location:
    Achewood, CA
    #3
    As far as I know there is no limit on the number of directories that can be nested. However, the longest an absolute path can be is 1024 characters (or whatever the value of PATH_MAX is). You'll probably start getting "file name too long" errors somewhere around the high hundreds of nested directories, depending on the lengths of their names.

    And yes, mkdir -p is the answer. Manpages are your friend.
     
  4. Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA

Share This Page