获取文件路径

根据定义的参数获取文件路径。

命令可用性: 本地 IBM RPA SaaS 和 IBM RPA

注:从发行版 18.1.0.9 开始,此命令为不推荐

脚本语法

IBM RPA 的专有脚本语言的语法与其他编程语言类似。 该脚本语法在脚本文件中定义命令的语法。 您可以在 IBM RPA Studio的 脚本 方式下使用此语法。

getFilePath --path(String) [--filemask(String)] [--orderbyname(Boolean)] [--orderbylastmodification(Boolean)] [--orderbyextension(Boolean)] [--orderbysize(Boolean)] [--reverseordering(Boolean)] --position(Numeric) [--fileSystem(FileSystem)] (String)=value

输入参数

下表显示了此命令中提供的输入参数的列表。 在表中,您可以看到在 IBM RPA Studio的脚本方式及其 Designer 方式等效标签中工作时的参数名称。

设计器方式标签 脚本方式名称 必需的 接受的变量类型 Description
目录 path Required Text 包含所需文件的文件夹。
过滤器 filemask Optional Text 搜索文件时使用的字符。
按名称排序 orderbyname Optional Boolean 启用以按名称对文件路径进行排序。
按上次修改日期排序 orderbylastmodification Optional Boolean 启用以按上次修改日期对文件路径进行排序。
按扩展名排序 orderbyextension Optional Boolean 启用以按扩展名的字母顺序对文件路径进行排序。
按大小排序 orderbysize Optional Boolean 启用以按大小对文件路径进行排序。
反向排序 reverseordering Optional Boolean 启用以对文件路径进行反向排序。
位置 position Required Number 所定义目录中文件的索引。
文件系统 fileSystem Optional File System 与文件系统的连接变量,如果为空白,那么将使用操作系统的文件系统。

输出参数

设计器方式标签 脚本方式名称 接受的变量类型 Description
路径 value Text 返回文件路径

示例

使用此命令按名称获取文件路径,并以日志消息形式返回该路径。

defVar --name desktop --type String
defVar --name file --type BinaryFileWriter
defVar --name path --type String
// Obtém o caminho da pasta "Desktop".
getSpecialFolder --folder "Desktop" desktop=value
// A .txt file with name "file" is created in this folder.
openBinaryWriter --mode "CreateNew" --autoflush  --share "Write" --path "${desktop}\\file.txt" --encoding "Default" file=value
// The command gets path of this file, filtering by name.
getFilePath --path "${desktop}" --filemask file --position 1 path=value
// Logging the path.
logMessage --message "${path}" --type "Info"