Checking the existence of a file with only part of the file's name [message #94598] |
Wed, 19 July 2017 09:07  |
thtran296
Messages: 8 Registered: June 2017
|
Junior Member |
|
|
Hello everybody,
So I have thousands of text files, with the names like "textABC05_023.tab"
I want to check if one of these files exists. So I use the following:
result = file_test('Documents/DataFile/textABC05_023.tab') & print, result
The problem is, this only works if I know the exact full name of the file. What if I only want to check the existence of files, given that I know only part of the name, like "textABC05" (omitting the "_023" part)?
Part of the reasons I want to do that is these files have really random numbers at the end, and all I care is whether their names match up to the part textABC05, and if they did, then they exist.
Thank you for all your assistance.
|
|
|
Re: Checking the existence of a file with only part of the file's name [message #94599 is a reply to message #94598] |
Wed, 19 July 2017 10:51  |
Craig Markwardt
Messages: 1869 Registered: November 1996
|
Senior Member |
|
|
On Wednesday, July 19, 2017 at 12:07:44 PM UTC-4, thtr...@gmail.com wrote:
...
> The problem is, this only works if I know the exact full name of the file. What if I only want to check the existence of files, given that I know only part of the name, like "textABC05" (omitting the "_023" part)?
It might be worth checking out the FILE_SEARCH() function.
Craig
|
|
|