英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论