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

huangapple go评论68阅读模式
英文:

How to find any "txt" file at particular location in system?

问题

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

file.exists ♥environment⟦USERPROFILE⟧\Documents\t.txt errormessage ‴对不起,我找不到文件‴
dialog ‴文件存在‴

英文:

I have a robot to find a file of the given name at a particular location in a system but now I want to find all the text files at that particular location. I have tried to use "*.txt", but it didn't worked out. Is there a way to do that?

file.exists ♥environment⟦USERPROFILE⟧\Documents\t.txt errormessage ‴Sorry, I could not find a file‴
dialog ‴File exists‴

答案1

得分: 1

你可以使用 directory 命令。pattern 参数允许你筛选特定扩展名的文件。

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

上面的代码应该能让你知道在给定目录中有多少个具有给定扩展名的文件。

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

英文:

You can use the directory command. The pattern arguments allows you to filter out files of a particular extension.

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

The above code should let you know how many files of the given extension exist in the given directory.

You could take values from the returned list and use it with file.exists command.

huangapple
  • 本文由 发表于 2020年1月7日 02:13:37
  • 转载请务必保留本文链接:https://go.coder-hub.com/59616947.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定