WAD The number of files and dirs are multiplied when using multiple wildcards

Jan 29, 2012
Russia, Novosibirsk
Hello All!

TCC 17.00.70 Windows 7 [Version 6.1.7601]

The number of files and dirs are multiplied when using multiple wildcards.
You can see this by running command:
dir *;*

Each file and dir is displayed twice. It is clear.

But there is also a not correct sorting for existing files "a*.*" in for /o:-d (a*;*) statement.

@echo off
*md !
*cd !
echo [1] FOR: output descending
for /o:-d /a:-d %i in ([12]*.*;[12]*) echo %i
echo [2] FOR: output ascending
for /o:d /a:-d %i in ([12]*.*;[12]*) echo %i
echo [3] DIR: output descending
dir /km /o:-d /a:-d [12]*.*;[12]*

А result that I got to watch in the screenshot.

/wnr, Alexander


  • TakeComman.v17-err-sort.JPG
    24.3 KB · Views: 105
Last edited:
Jan 29, 2012
Russia, Novosibirsk
FOR /O:-D sorting worked in previous versions differently than it is now in version 17. :banghead:

Ok, I made changes to my script. Thank You. :smile:

p.s. I would like to correct the name of the theme.
There is bug in not multiple wildcards of the DIR command and sorting of the FOR command.
Or is it not a mistake but an improvement or a new look of the FOR command (or hidden new features).


Staff member
May 14, 2008
WAD - when you use the correct syntax. Note that "*" and "*.*" are identical on an NTFS (or any LFN) volume - they will only return (partially) different results if you're on a FAT16 volume.

If you change your batch file to:

@echo off
*md !
*cd !
echo [1] FOR: output descending
for /o:-d /a:-d %i in ([12]*) echo %i
echo [2] FOR: output ascending
for /o:d /a:-d %i in ([12]*) echo %i
echo [3] DIR: output descending
dir /km /o:-d /a:-d [12]*

you'll see that it returns the expected results:

[1] FOR: output descending
[2] FOR: output ascending
[3] DIR: output descending
 1/18/2015  9:24  0  2
 1/18/2015  9:24  0  1

Nothing changed in v17 with the handling of /O:xxx. (However, using /O:xxx with FOR can be highly problematic if FOR is doing anything to change the directory contents.)
Jan 29, 2012
Russia, Novosibirsk
Yeah, inadvertently I gave in my example de-duping file patterns. I'm sorry. This was due Friday.
My working version of wildcards in a script excludes duplicate files, viz. %[fn][!a-z]*.txt;%[fn].txt

@echo off %+ setlocal
ver %+ set td=!
if not isdir %td *md %td
echos> .\%[td]\a1.txt
echos> .\%[td]\a2.txt
echos> .\%[td]\b.txt

for k in (a b) gosub ABC %k

:ABC [fn]
echo [1] FOR: output descending
for /o:-d /a:-d %i in (.\%[td]\%[fn][!a-z]*.txt;%[fn].txt) (echo %i %+ LEAVEFOR)
echo [2] FOR: output ascending
for /o:d  /a:-d %i in (.\%[td]\%[fn][!a-z]*.txt;%[fn].txt) (echo %i %+ LEAVEFOR)
echo [3] DIR: output descending
dir /km /o:-d /a:-d .\%[td]\%[fn][!a-z]*.txt;%[fn].txt

I agree that this is precarious decision. But it worked several years.
I would like only to draw your attention to the different behavior of the FOR command in Take Command v17.
See attached file.

/wnr, Alexander


  • TakeCommand-FOR-ORDER-v17.png
    21.9 KB · Views: 113
Similar threads
Thread starter Title Forum Replies Date
R FUNCTION to count NUMBER of files matching a pattern and specific length/not length Support 4
vefatica Windows 10 version number? Support 6
T FFind - can we display n number of lines after the find? Support 2
H DOS CMD Sort+Add Sequence+Remove Sequence number Support 12
Roedy WAD Version number Support 1
C How to? date1 - date2 = number of days Support 10
nikbackm FUNCTION with variable number of arguments Support 17
C Does removing a registered TCMD lower the number registrations used? Support 5
C How to? KEYSTACK's /W number for 5 minutes Support 2
A How to? Filter a list by numeric number within filename Support 28
M How to? A very simple question re. the current line number in a batch file... Support 2
R specific functions for number conversion Support 2
MickeyF TCC crashing when copying multiple files (now resolved) Support 6
fpefpe How to? shortcuts and batch files Support 4
C v28 key files Support 2
J ffind does not find files Support 4
C duplicate files in multiple plugin sites Support 9
Dmitry L. Kobyakov Fixed The SETARRAY /R command works incorrectly with cyrillic files Support 2
S How to? Deinstalling TC/reinstating execution of bat files by cmd in Win7 Support 31
vefatica FFIND, temp files? ... not deleted? Support 0
vefatica Tmp files from in-process pipes not deleted Support 6
vefatica Finding files with alternate data streams? Support 4
rps Multi-column DIR /v not displaying all files. Support 5
D How to skip files in a fileset? Support 6
vefatica PIPEVIEW leaves TMP files Support 18
K "copy /z /w" command not deleting read-only files in destination Support 10
Jesse Heines "Taken" date for JPG and PNG files Support 4
O I cannot use links to .btm files Support 5
C How to? rename files with spaces Support 8
R How to? Append files in multiple subfolders using copy? Support 8
Joe Caverly "Functions" in cmd.exe batch files Support 6
S Batch files Calling Batch Files Support 2
vefatica Find Files/Text dialog: does it work? Support 0
Joe Caverly UNZIPping older .ZIP files Support 3
C Documentation default location for LOG files Support 21
P exit /b in batch files Support 7
P Labels in batch files: TCC vs CMD.exe Support 9
M ANSI is used to show files instead of OEM in version 17 to 19 ! Support 5
C 7Z files on forum? Support 0
x13 Problem listing repository files using DIR http(s)://... Support 8
B Can copy command concatenate multiple mp3 files Support 2
redwdc Copying files with spaces, commas, etc. Support 5
J New lexer for TCC batch files. Support 0
M How to? want to download a file from a website enumarate the links and download the files Support 2
keithg1964 TCC RT Install Files Support 1
P Fixed Rexx .cmd files no longer work in TCC 20 Support 3
thorntonpg Handling files with embedded spaces Support 1
WavSlave Fixed Unable to sort files by description in TCC v19 Support 2
P Files older - exist Support 1
D safe delete files command Support 10

Similar threads