Back in July last year I posted MKDIRMD Macro: Creating Tree Folders in Metadata about a SAS macro I wrote to create tree folders in a SAS metadata repository using the SAS Open Metadata API. Just recently I discovered an alternative method using a utility already present in a SAS 9.2 installation: MakeFolder.
I stumbled on MakeFolder in passing whilst looking in the SASPlatformObjectFramework directory (which is /usr/local/SAS/SASPlatformObjectFramework/9.2 on my Linux machine). If you haven’t seen it before, that directory contains a number of tools such as the Batch Export and Import tools for batch migration/promotion of metadata and the ValidateServer utility mentioned in SAS Usage Note 42523: ValidateServer utility to check availability of SAS® 9.2 Business Intelligence servers. I noticed the SASPlatformObjectFramework directory contained a few other utilities too, including MakeFolder which sounded very much like it might, well, make a folder! Since there are already operating system commands to make file system folders I guessed it would probably make metadata folders and so be worth a closer look.
I couldn’t find any documentation for MakeFolder. A search on support.sas.com yielded nothing. The other SASPlatformObjectFramework utilities documented –help parameters so I thought I would try that out first. It displayed the following nice usage message:
userid@host:~$ /usr/local/SAS/SASPlatformObjectFramework/9.2/MakeFolder --help
usage: MakeFolder [options...] folderPath
options include:
-profile <profile> Metadata server connection profile. Can be used in
place of the -host, -port, -user, and -password options.
-user <userID> User login identity. Required if -profile is not set or
if the profile does not contain connection credentials.
-password <password> User login password. Required if -profile is not set or
if the profile does not contain connection credentials.
-host <hostname> Metadata server host. Required if -profile is not set.
-port <port> Metadata server port. Required if -profile is not set.
-?,--help Print help information.
-domain <domain> User authentication domain
-log <log-file> Log file or directory.
-makeFullPath create intermediate folders if necessary
It all looked quite straightforward, so I tried it out in a development environment. Firstly to create a simple top level folder (/testsimple):
userid@host:~$ /usr/local/SAS/SASPlatformObjectFramework/9.2/MakeFolder -host localhost -port 8563 -user adminpaul@saspw -password thesecretpassword /testsimple
INFO *** Make Folder started on 26/05/2011 ***
INFO Server localhost:8563, user adminpaul@saspw.
INFO Folder /testsimple created.
MakeFolder has completed.
That worked fine and looking in the SAS Management Console Folders tab I could see the folder had been created.
There was also a -makeFullPath to create intermediate parent folders too. I first tried it out without -makeFullPath:
userid@host:~$ /usr/local/SAS/SASPlatformObjectFramework/9.2/MakeFolder -host localhost -port 8563 -user adminpaul@saspw -password thesecretpassword /test/multiple/levels
INFO *** Make Folder started on 26/05/2011 ***
INFO Server localhost:8563, user adminpaul@saspw.
ERROR Parent folder /test/multiple/ does not exist.
MakeFolder has completed.
As expected, that produced an error message since I didn’t already have the /test/multiple parent folders. I ran it again, this time with the -makeFullPath parameter:
userid@host:~$ /usr/local/SAS/SASPlatformObjectFramework/9.2/MakeFolder -host localhost -port 8563 -user adminpaul@saspw -password thesecretpassword -makeFullPath /test/multiple/levels
INFO *** Make Folder started on 26/05/2011 ***
INFO Server localhost:8563, user adminpaul@saspw.
INFO Folder /test/ created.
INFO Folder /test/multiple/ created.
INFO Folder /test/multiple/levels created.
MakeFolder has completed.
The folder and its parents were all created successfully.
MakeFolder indeed looks very useful. However, since I haven’t seen any official SAS documentation for it, I would err on the conservative side and, unless I hear otherwise, assume it’s not currently supported. Perhaps if someone from SAS Institute is reading they might be able to provide a bit more info about its status.
So now I know two ways to script the creation of metadata folders.
Great finding! I used the makefolder.exe to facilitate and most of all automate (using a .bat script) the creation of folder in a SAS Rmfi context.
In a windows environment one needs to use quotes around path if it contains spaces.
options are case sensitive. Thus -Port for example won’t work as it expects -port.
Hi Joao,
Thanks for the usage tips.
Cheers
Paul
Great find!
I, as you did, stumbled across this utility when browsing through the SASPlatformObjectFramework folder. Actually, I have discovered that the batch import utility does not work if the intermediate folders are not present. So I already had on my todo list to find a way of creating the folders upfront! ;)