I have a question about searching for files in Windows Server 2008 R2. We are automating Excel (don't ask) which when fails can leave behind the temporary files that have an extension of .XLS~
If I do a manual search for *.xls~ it appears that Server 2008 is treating the tilde as a wildcard and returning ALL *.xls files, which of course is not what I want.
Can anyone please tell me how I can do this search so it will bring back the correct files? Is there an escape character I can use? Someone told me to use double quotes and try searching for *."xls~" but that doesn't work.
Best Answer
The "~" character is an operator in the Advanced Query Syntax used by Windows Search.
By itself, it indicates that a search contains wildcards, as in
System.FileName:~"Mic?osoft W*d"
matching a filenameMicrosoft Word
.To literally match the "*.xls~" filename you would search for
System.Filename:~"*.xls~"
My old, less-well-informed answer, which I am only keeping around because of the novelty of piping to the clipboard, this:
I'd throw open a command prompt and do a
dir /b /s/a x:\*.xls~
(substituting in the appropriate drive letter). If you want the list on the clipboard add a| clip
to the command. You won't get your files in a pretty Explorer view, but you will get a list.If you want to do that w/o leaving your GUI just open the "Run" box and put in
cmd /c dir /s /a /b x:\*.xls~ | clip
and, after thecmd.exe
window closes you'll have your results on the clipboard.