Take the 2-minute tour ×

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 stackoverflow.com 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

1 Answer 1

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

Your Answer


