我有一个机器人,可以在系统中的特定位置查找具有给定名称的文件,但是现在我想在该特定位置查找所有文本文件。我尝试使用“ * .txt”,但没有成功。有没有办法做到这一点?
file.exists ♥environment⟦USERPROFILE⟧\Documents\t.txt errormessage ‴Sorry, I could not find a file‴
dialog ‴File exists‴
您可以使用directory命令。 pattern
参数允许您过滤出特定扩展名的文件。
directory path ♥environment⟦USERPROFILE⟧\Desktop pattern *.txt result ♥files
dialog ♥files⟦count⟧
上面的代码应该让您知道给定目录中存在给定扩展名的文件数。
您可以从返回的列表中获取值,并与file.exists
命令一起使用。