4

I accidentally entered this command in a big working directory and got this result:

d:\prog>move ^<
       10 file(s) moved.

Can someone explain what have I just done? I have no idea :/

Note:

This only seems to happen if there are files in the directory with just an extension (and no name), for example .a.

enter image description here

10
  • Are you sure move ^< was the complete command? I get "The filename, directory name, or volume label syntax is incorrect." with that command.
    – DavidPostill
    Nov 1, 2015 at 10:35
  • I also get that at other directories, so it seems something related to the directory contents... now I got an idea and created a file named .a, repeating the move ^< command resulted in 1 file(s) moved. So it might do something with files named .something, but I still don't know what it does...seemingly nothing, but I'd be happier if I knew how it worked :) Nov 1, 2015 at 10:39
  • Hmm. With a file named .a. I can reproduce it. It doesn't actually move anything though ... investigations continue
    – DavidPostill
    Nov 1, 2015 at 10:42
  • -1 do a DIR, make it so it's reproducable / clear how others can reproduce it. e.g. when I tried it, even after creating a file you didn't mention, I got an error message i.imgur.com/w0qidGr.png So i'd like to see more info about what's in d:\prog and your windows version
    – barlop
    Nov 1, 2015 at 10:58
  • Normally < is the redirect command for stdin. ^ is the escape character so ^< means a literal < character. So move ^< should mean move a file called < to the current directory. However < is not a valid filename ...
    – DavidPostill
    Nov 1, 2015 at 10:59

1 Answer 1

2

You are using a wildcard, so, matching files are moved. Microsoft documentation (links at the bottom) states

  • DOS_QM (> greater than) Matches any single character or, upon encountering a period or end of name string, advances the expression to the end of the set of contiguous DOS_QMs.

  • DOS_STAR (< less than) Matches zero or more characters until encountering and matching the final . in the name.

So, your command is "moving" (as the target folder is the same as the source there is no real move operation) files without extension, that is, your command is equivalent to move *.

Now the next question should be:

  • If the ^< (or just "<") is selecting files without extension, why .a file that has no name, it only has extension, gets selected?

And the answer is short names. Wildcard selection work on long and short names of the files. If you try with dir /x to list the files short names, you will probably see that the short name for the .a file has no extension.

More information

2
  • Hmm. So why doesn't dir ^> match a.?
    – DavidPostill
    Nov 3, 2015 at 19:26
  • @DavidPostill, for me ^> and ">" match all files with a single character in its name and no extension. If you included the dot in the name (not the extension separator) then the file name has two characters and it is not matched.
    – MC ND
    Nov 3, 2015 at 19:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .