使用SAP BODS脚本创建目录

时间:2018-10-26 10:14:40

标签: directory sap business-objects

如何在Windows上使用SAP Business Objects Designer 4.2脚本在给定路径中创建目录?

我得到了一个脚本,其中包含我想创建的路径(如果不存在)

$My_Path = '\\\\localsrv\\source data\\post\\november'

我当前的网络位置仅包含以下内容:

\\localsrv\source data\

我想在该位置创建子目录postpost\november

1 个答案:

答案 0 :(得分:0)

脚本中,我们需要使用exec()函数,该函数向操作系统发送命令以执行。它需要以下参数:

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
)

也就是说,只需使用cmdmd命令在Windows上创建带有子目录的目录,然后将其与if not exists结合使用,以跳过尝试在目录已经存在时创建目录的情况。

脚本如下:

$My_Path = '\\\\localsrv\\source data\\post\\november'
exec('cmd', 'if not exists "[$My_Path]" md "[$My_Path]"');