Home > Software engineering >  Windows command line wildcard expansion order
Windows command line wildcard expansion order

Time:12-05

When you issue the following copy with concatenation command in Windows:

copy /b *.txt elsewhere\all.txt

Is there any way to control the order of source files? A quick test suggests alphabetic sorting, but is there any guarantee?

CodePudding user response:

First, there's no wildcard expansion in cmd like in bash. The command will receive the arguments as-is. In the copy command it passes the wildcard to FindFirstFile which returns files in whatever order the file system presents. In NTFS they're stored in a B-tree structure so if you use English it'll appear to be in alphabetic order, but it won't be like that in other languages or if there are special characters/special collocation rules. On a FAT32 drive files are stored linearly in the file allocation table so files would be listed in the order in that table

See

  • Related