1

I have a number of files with a 3 digit prefix. I'm attempting to move files based on the prefix using a wildcard. I expect that

move 100*.sql subdir

would only move files with the .sql extension that begin with the characters "100" to the "subdir" folder, but the command results in the following. Notice the last file copied is prefixed with 106 rather than 100.

D:\100-20141017-120703.sql
D:\100-20141020-150709.sql
D:\100-20141020-180711.sql
D:\100-20141021-100714.sql
D:\100-20141021-150704.sql
D:\100-20141021-180728.sql
D:\100-20141022-100729.sql
D:\100-20141022-130727.sql
D:\100-20141022-180724.sql
D:\100-20141023-100725.sql
D:\100-20141023-134946.sql
D:\100-20141024-100733.sql
D:\100-20141030-090703.sql
D:\100-20141030-100711.sql
D:\100-20141031-100712.sql
D:\100-20141101-100705.sql
D:\100-20141103-100715.sql
D:\100-20141105-100706.sql
D:\100-20141106-130709.sql
D:\100-20141110-150710.sql
D:\100-20141110-154721.sql
D:\100-20141111-160704.sql
D:\100-20141114-100705.sql
D:\106-20141029-150706.sql
24 file(s) moved.

How can I prevent this. Apologies if this has been asked/answered previously. I searched to no avail.

Thank you,

7
  • I'm unable to reproduce this bug on Windows 7. – krowe Nov 17 '14 at 23:32
  • Normally these issue wont occur since you have mention in query to move files with prefix 100. Can you please provide some more information on this case like Os version, and is that the issue is occurring frequently/ reproducing again – vembutech Nov 17 '14 at 23:59
  • troubleshoot it further. copy the one problem file to another directory see if it still happens when it's alone. try making the filename just 106.sql see if it still gets matched by 100*.sql if so you're narrowing it down. if not then you're narrowing it down – barlop Nov 18 '14 at 0:01
  • Are there more files unmoved with 106*.sql pattern in the source directory? What about output from dir /B subdir\100*.sql - is it as expected, or the same issue? – JosefZ Nov 18 '14 at 0:21
  • The problem are the sort names generated for the files in the folder. The wildcard will retrieve anything matching both long or short names. Try a dir /x to see why the files are selected. – MC ND Nov 18 '14 at 12:24
0

It looks like the problem is related to the hyphen after the 3 digit prefix. If I include the hyphen in the command, the results are correct:

Results without hyphen(includes 106 prefixed file):

D:\>dir 100*.sql
 Directory of D:\
10/17/2014  11:07 AM            22,716 100-20141017-120703.sql
10/20/2014  02:07 PM             1,761 100-20141020-150709.sql
10/20/2014  05:07 PM             7,016 100-20141020-180711.sql
10/21/2014  09:07 AM             3,524 100-20141021-100714.sql
10/21/2014  02:07 PM             3,500 100-20141021-150704.sql
10/21/2014  05:07 PM             3,518 100-20141021-180728.sql
10/22/2014  09:07 AM             7,028 100-20141022-100729.sql
10/22/2014  12:07 PM            10,522 100-20141022-130727.sql
10/22/2014  05:07 PM             5,263 100-20141022-180724.sql
10/23/2014  09:07 AM             3,502 100-20141023-100725.sql
10/23/2014  12:49 PM             1,751 100-20141023-134946.sql
10/24/2014  09:07 AM             7,844 100-20141024-100733.sql
10/30/2014  08:07 AM             1,755 100-20141030-090703.sql
10/30/2014  09:07 AM             1,751 100-20141030-100711.sql
10/31/2014  09:07 AM            12,706 100-20141031-100712.sql
11/01/2014  09:07 AM             2,169 100-20141101-100705.sql
11/03/2014  10:07 AM             1,757 100-20141103-100715.sql
11/05/2014  10:07 AM             1,747 100-20141105-100706.sql
11/06/2014  01:07 PM             1,763 100-20141106-130709.sql
11/10/2014  03:07 PM             8,771 100-20141110-150710.sql
11/10/2014  03:47 PM             1,753 100-20141110-154721.sql
11/11/2014  04:07 PM             1,749 100-20141111-160704.sql
11/14/2014  10:07 AM             1,751 100-20141114-100705.sql
10/29/2014  02:07 PM                 0 106-20141029-150706.sql
              24 File(s)        115,617 bytes

Results with hyphen(does not include 106 prefixed file):

D:\>dir 100-*.sql
 Directory of D:\
10/17/2014  11:07 AM            22,716 100-20141017-120703.sql
10/20/2014  02:07 PM             1,761 100-20141020-150709.sql
10/20/2014  05:07 PM             7,016 100-20141020-180711.sql
10/21/2014  09:07 AM             3,524 100-20141021-100714.sql
10/21/2014  02:07 PM             3,500 100-20141021-150704.sql
10/21/2014  05:07 PM             3,518 100-20141021-180728.sql
10/22/2014  09:07 AM             7,028 100-20141022-100729.sql
10/22/2014  12:07 PM            10,522 100-20141022-130727.sql
10/22/2014  05:07 PM             5,263 100-20141022-180724.sql
10/23/2014  09:07 AM             3,502 100-20141023-100725.sql
10/23/2014  12:49 PM             1,751 100-20141023-134946.sql
10/24/2014  09:07 AM             7,844 100-20141024-100733.sql
10/30/2014  08:07 AM             1,755 100-20141030-090703.sql
10/30/2014  09:07 AM             1,751 100-20141030-100711.sql
10/31/2014  09:07 AM            12,706 100-20141031-100712.sql
11/01/2014  09:07 AM             2,169 100-20141101-100705.sql
11/03/2014  10:07 AM             1,757 100-20141103-100715.sql
11/05/2014  10:07 AM             1,747 100-20141105-100706.sql
11/06/2014  01:07 PM             1,763 100-20141106-130709.sql
11/10/2014  03:07 PM             8,771 100-20141110-150710.sql
11/10/2014  03:47 PM             1,753 100-20141110-154721.sql
11/11/2014  04:07 PM             1,749 100-20141111-160704.sql
11/14/2014  10:07 AM             1,751 100-20141114-100705.sql
              23 File(s)        115,617 bytes

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.