Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question
    
I don't get that behavior. When searching for *.xls~ I get only files named "filename.xls~" –  joeqwerty Mar 11 '11 at 4:14
1  
Have you tried searching for "*.xls~" (the whole thing in quotes, not just the extension)? –  John Gardeniers Mar 11 '11 at 4:21

3 Answers 3

I'm repro'ing the behavior fine in W2K8R2's Explorer. It looks like a "feature" to me.

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 the cmd.exe window closes you'll have your results on the clipboard.

share|improve this answer
    
I don't know why but that's the first time I've ever seen a command piped straight to the clipboard. Thanks for the tip. –  John Gardeniers Mar 11 '11 at 4:22
    
@John Gardeniers: I find myself, fairly regularly, running cmd /c xxxx commands from the GUI. If I need to make a directory somewhere, copy some files, etc, that's what I'll do if I don't already have a shell open somewhere. Typing cmd /c is very quick... >smile< –  Evan Anderson Mar 11 '11 at 13:07

~ is not a wildcard in PowerShell, so:

dir startingPath -recurse -filter '*.xls~'
share|improve this answer

Assuming you're talking about Windows Search, try ~*".xls~" This also helps with parentheses, e.g. ~*"(1).xls"

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.