Posts: 1,058
Threads: 367
Joined: Oct 2007
Supposed that in a folder exists a short path file, ie. C:\tmp\FW730~1.eml. How is it possible to locate this file using a search engine, for example a foreach(d s FE_Dir) command. More specifically is there a way to use in this statement the tilde (~) character (actually I did not manage to elaborate it), or is there another way to do it.
Thanks in advance.
Posts: 12,141
Threads: 143
Joined: Dec 2002
Macro
Macro1282
_s.setfile("$temp$\abcdef~1.txt")
_s.setfile("$temp$\abcde~12.txt")
_s.setfile("$temp$\abcd~123.txt")
_s.setfile("$temp$\abc~1234.txt")
out
ARRAY(str) a
GetFilesInFolder a "$temp$" "^(.{6}~\d{1}|.{5}~\d{2}|.{4}~\d{3}|.{3}~\d{4})\.[^\.]{3}$" 0x10004
int i
for i 0 a.len
,out a[i]
Posts: 1,058
Threads: 367
Joined: Oct 2007
Dear Gintaras,
Many thanks, but my question was slightly different. In the follwing example :
Macro
temp1
_s="C:\tmp\???"
foreach(d _s FE_Dir)
,str sPath=d.FileName(1)
,out sPath
What is the value of ??? to enumerate files with ad least one tilde character in th filename.
Thanks
Simos
Posts: 1,058
Threads: 367
Joined: Oct 2007
Thanks again. Yes, I tried what you propose in the beginning, before writing this post. But it does not work in that it gives more files than these which they actually contain a tilde in the file name. I cannot understand why. I can send an example if you find it useful.
Posts: 12,141
Threads: 143
Joined: Dec 2002
Yes I tested it. Could use "*~*", but then finds all files. It is how Windows works. Files have 2 names - long and short with ~, and Windows (particularly FindFirstFile , that QM calls) finds both.
If want to use FE_Dir or dir, need to get all files and then use findc('~') or other string function.
Posts: 1,058
Threads: 367
Joined: Oct 2007
Perfect advice. Best regards.