Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

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

Jan
16
0
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:
Code:
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.

Code:
@echo off
*md !
*cd !
echos>1
echos>2
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
 

Attachments

  • TakeComman.v17-err-sort.JPG
    TakeComman.v17-err-sort.JPG
    24.3 KB · Views: 291
Last edited:
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).
 
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:

Code:
@echo off
*md !
*cd !
echos>1
echos>2
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:

Code:
[1] FOR: output descending
2
1
[2] FOR: output ascending
1
2
[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.)
 
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

Code:
@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
quit

: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
return

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
 

Attachments

  • TakeCommand-FOR-ORDER-v17.png
    TakeCommand-FOR-ORDER-v17.png
    21.9 KB · Views: 286

Similar threads

Back
Top