Create Multiple Directory Levels in One Swell Foop
January 30, 2008 Hey, Professional
Yes, you, the person who knows so much about making machinery serve your organization. You, the person who knows so many little, seemingly trivial and insignificant bits and pieces of information. Here’s a bit of info that maybe no one in your shop knows, and it can come in handy. It comes from the IT Jungle Web forums.
Here’s the original question, after a bit of editing.
During a payroll run, I need to create multiple directories (which will be subdirectories) that will contain various reports, for specific companies, for specific pay dates. The company directories already exist. For example:
/reports/01 /reports/02 /reports/03
I need to create a process to create a subdirectory for the pay period. For example:
/reports/01/042106 /reports/02/042106 /reports/03/042106
Can anyone offer me some insight into the best way to approach this task?
“Russ K” (a really sharp consultant from New Jersey) and I tried to help this person. I’m not sure if we succeeded, but in the process we discovered something else: the OS/400 directory creation commands (CRTDIR, MKDIR, and MD) don’t support the creation of more than one level of directory at a time.
While researching another problem, I discovered that Qshell’s MKDIR command has a “-p flag” that allows you to create more than one level of directory at once. For example, the following command will create as many as five levels of directory.
mkdir -p /home/tholt/reports/2007/12
If you’d like to read the entire thread, click on this link.
If you’d like to participate in the Web forums, but are having trouble getting your account activated, please email me through the Contacts link at the top of this page. Be sure to use an appropriate subject line so I won’t confuse your email for spam.