Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using the "move" command with a wildcard pattern in the CMD prompt under Windows 7.

In my source directory, I have the following files:


If I type the command move source\*.avi dest it will move all four files even though I would expect it to only move the two *.avi files and not the *.avi_metadata files.

As expected, move source\*.a dest and move source\*.av dest don't move any files. However when the length of the extension for the wildcard pattern is 3 characters, it will move all extensions that begin with those first three characters.

Is this a bug in the "move" command or expected behavior and is it documented anywhere?

Edit: John Watts notes that this is probably do to "short" filenames.

Is it possible then to make commands in the CMD interpreter only operate on long filenames and to ignore short filenames?

share|improve this question

migrated from Sep 1 '12 at 9:37

This question came from our site for professional and enthusiast programmers.

Does windows 7 still create 8.3 names? Because those would match *.avi for all four files. – John Watts Aug 30 '12 at 16:03
Ah... short file names... you bite me in the butt. Thanks John. BTW, I wonder who downvoted this. It's a legitimate question. – Adisak Aug 30 '12 at 16:04
It probably belongs on superuser. It is more appropriate to move it than downvote, but they may not have enough rep for that. – John Watts Aug 30 '12 at 16:07
Well, it's certainly something that affects BATCH programming. I'm not even sure how to move it to a different StackExchange site :-( – Adisak Aug 30 '12 at 16:11
you could disable creation of short filenames on ntfs using fsutil: fsutil behavior set disable8dot3 1. This affects only files created after the change. – wmz Aug 30 '12 at 18:55
up vote 2 down vote accepted

You can pipe DIR /B through FINDSTR to filter out the unwanted files. You can process those results using FOR /F.

for /f "eol=: delims=" %F in ('dir /b /a-d source\*.avi^|findstr /lie .avi') do move "source\%F" dest
share|improve this answer
Thank you for the useful work-around to the problem. – Adisak Aug 30 '12 at 22:22

You must log in to answer this question.

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