Why does "dir *.*~" list files in a way different to what is expected?

2

In my directory I have the files files

  • x.dll
  • x.lib
  • x.pdb
  • x.exp
  • x.plugin

When I issue the command dir \*.*~ it should say 'File not found' as it does at my friend's laptop. But on my machine it lists the file x.plugin.

Actually after a while of trying I found out that it lists all files with extension longer than 3 characters.

Anybody heard about this behavior before?

rezna

Posted 2012-10-19T09:02:58.303

Reputation: 191

This is Windows 7 you are using? – Groo – 2012-10-19T09:12:58.310

yes it is. and it must be quite a new behavior, as it used to work correctly (means only files like x.bak~ being returned for the supplied wildcard) – rezna – 2012-10-19T09:18:50.333

Windows 7 extends the way you can use wildcards (check this answer). But adding a tilde (~) at the end doesn't seem supported, so the result may be undefined, as you're getting. Adding it at the beginning of the query should tell Win 7 to use DOS style syntax for wildcards (but the tilde itself will be ignored).

– Groo – 2012-10-19T09:23:34.730

@Groo: AQS does not seem to be supported at all by the dir command though. – Marcks Thomas – 2012-10-19T09:53:27.800

XP I just get file not found. Even when extension is over 3 char. And even when there are files starting with ~ , and even when there's a file with both features ~df.adfdfd it says File Not Found. What even caused you to do dir .~ ? – barlop – 2012-10-19T09:56:31.753

Answers

1

Seeing the command dir *.*~, I would assume it lists all files in the directory.

The * placeholder means 'any number of any character'.

If you want to find all files ending in xx~, I would use the command dir *.??~. The '?' means 'any one character'.

At least, this used to be so in the 'old' DOS days...

user80393

Posted 2012-10-19T09:02:58.303

Reputation: 146

this used to work - and still it works on my friend's machines .~ returns all files who's extension ends with '~' - this means, lists all backup files which for example jEdit creates – rezna – 2012-10-19T10:48:17.480

@rezna does your friend have a different cmd.exe ? like a different size? (as the dir command is within that file), so i'm wondering if he has a different dir command. – barlop – 2012-10-22T15:59:06.420