How does one create directories in a given path on Windows using SAP Business Objects Designer 4.2 Script?
I got a Script with path that I'd like to create if it does not exist:
$My_Path = '\\\\localsrv\\source data\\post\\november'
My current network location only cosists of:
\\localsrv\source data\
And I would like to create subdirectories post
and post\november
within that location.
In Script we need to use an exec()
function which sends a command to operating system for execution. It takes below arguments:
exec(
<command file> -- for example cmd or bat
<parameter_list> -- values to pass as arguments to the command line
<flag> -- defines action upon error or nonzero return code
)
That said, simply use cmd
and md
command to create directories with subdirectories on Windows and combine it with if not exists
to skip trying to make a directory when it already exists.
Script will look like:
$My_Path = '\\\\localsrv\\source data\\post\\november'
exec('cmd', 'if not exists "[$My_Path]" md "[$My_Path]"');