如何在系统中的特定位置查找任何“ txt”文件?

问题描述 投票:1回答:1

我有一个机器人,可以在系统中的特定位置查找具有给定名称的文件,但是现在我想在该特定位置查找所有文本文件。我尝试使用“ * .txt”,但没有成功。有没有办法做到这一点?

file.exists ♥environment⟦USERPROFILE⟧\Documents\t.txt errormessage ‴Sorry, I could not find a file‴
dialog ‴File exists‴
automation rpa g1ant
1个回答
0
投票

您可以使用directory命令。 pattern参数允许您过滤出特定扩展名的文件。

directory path ♥environment⟦USERPROFILE⟧\Desktop pattern *.txt result ♥files
dialog ♥files⟦count⟧

上面的代码应该让您知道给定目录中存在给定扩展名的文件数。

您可以从返回的列表中获取值,并与file.exists命令一起使用。

© www.soinside.com 2019 - 2024. All rights reserved.