Create Multiple Directory Levels in One Swell Foop
December 5, 2007 Hey, Ted
Maybe I’m getting old, but I seem to remember being able to create several levels of directory structure with one command. I currently have such a need, in an application that creates XML files in the IFS. Yet CL’s MAKE DIRECTORY (MKDIR) command fails with error message CPFA0A9. Am I imaging things, or has something changed?
My guess is that you’re remembering MS-DOS’s md command. The following example contains a command that creates from one to five directories as needed.
C:>md salesreports2007 1RegionC
CL’s MKDIR command can only create one directory level at a time. However, Qshell’s mkdir command can create multiple levels at once if you use the p switch.
mkdir -p /home/sales/reports/2007/01/RegionC
The reason this answer comes to mind so quickly is that we had a discussion about this topic awhile back on the IT Jungle Web forums. You can read the thread here.
Anyone who wishes to participate in the forums but can’t get their account activated can email me through the IT Jungle contacts page. Put a meaningful sentence in the subject line so I don’t lose the email in the spam.