1

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:

 movie1.avi
 movie1.avi_metadata
 movie2.avi
 movie2.avi_metadata

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?

7
  • 2
    Does windows 7 still create 8.3 names? Because those would match *.avi for all four files.
    – John Watts
    Aug 30, 2012 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, 2012 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, 2012 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, 2012 at 16:11
  • 2
    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, 2012 at 18:55

1 Answer 1

2

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
0

You must log in to answer this question.

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