使用 SAP BODS 脚本创建目录?

Create directory using SAP BODS script?

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

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

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

我当前的网络位置仅包含:

\localsrv\source data\

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

Script中我们需要使用一个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]"');