【问题标题】:Create directory using SAP BODS script?使用 SAP BODS 脚本创建目录?
【发布时间】:2018-10-26 10:14:40
【问题描述】:

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

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

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

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

\\localsrv\source data\

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

【问题讨论】:

    标签: directory business-objects sap-data-services


    【解决方案1】:

    脚本中,我们需要使用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
    )
    

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

    脚本将如下所示:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-12-25
      • 2021-03-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-01-20
      • 2011-07-26
      相关资源
      最近更新 更多