@Files sure doesn't work the way I would have assumed it did!

May 24, 2010
855
0
Northlake, Il
I thought I'd do a little experimentation to determine if there was a way to work around the problem I mentioned in my previous posting. Well it turns out that I am dead in the water because @Files doesn't work anything close to the way I thought it would, and I'm wondering if it is working the way it should. For illustration, the following TCC session:
Code:
[Z:\TestAtFiles]*dir /S .

 Volume in drive Z is RAM Disk       Serial number is 8ab4:1647
 Directory of  Z:\TestAtFiles\*

12/26/2012  13:27         <DIR>    .
12/26/2012  13:27         <DIR>    ..
12/26/2012  13:10         <DIR>    A Directory
12/26/2012  13:10               0  A File.ext
                 0 bytes in 1 file and 3 dirs

 Directory of  Z:\TestAtFiles\A Directory\*

12/26/2012  13:10         <DIR>    .
12/26/2012  13:10         <DIR>    ..
                 0 bytes in 0 files and 2 dirs

    Total for:  Z:\TestAtFiles\A Directory\*
                 0 bytes in 0 files and 2 dirs    0 bytes allocated

    Total for:  Z:\TestAtFiles\*
                 0 bytes in 1 file and 5 dirs    0 bytes allocated
       143,740,928 bytes free

[Z:\TestAtFiles]Echo %@Files[/S *]
6

[Z:\TestAtFiles]Echo %@Files[/S *??.??*]
6

[Z:\TestAtFiles]ver

TCC  14.03.53 x64   Windows 7 [Version 6.1.7601]

[Z:\TestAtFiles]
The pattern that doesn't work is supposed to mean "a dot is required as well as at least two characters before and after the dot".

Clearly, it would appear that the wildcards are being totally ignored. And I will note that the documentation for @File clearly says "Filename may contain wildcards". Well it turns out that a question mark matches a null (i.e., missing) character, which I had never realized before. But even given that, why does a pattern of "???.????" match a file named just "a"? (And is there any way to accomplish what I am trying to achieve other than writing a C++ program?)
 
May 20, 2008
11,432
99
Syracuse, NY, USA
The pattern that doesn't work is supposed to mean "a dot is required as well as at least two characters before and after the dot".

You could use a regular expression. In the Perl syntax, "::.{2}\..{2}" seems to do the job.

Butt there's a slight discrepancy I can figure out. Below, @FILES counts 120 while DIR counts 119!
Code:
v:\> echo %@files["::.{2}\..{2}"]
120
 
v:\> *dir /u "::.{2}\..{2}"
 
Volume in drive V is DATA          Serial number is c007:d3e4
Directory of  V:\::.{2}\..{2}
 
      136,482,988 bytes in 119 files and 0 dirs    136,806,400 bytes allocated
    6,785,912,832 bytes free
 
May 24, 2010
855
0
Northlake, Il
Thank you, Vince. But between my blindness, bad memory, and the fact that I've used so many regular-expression syntax rules in the past 40 years it just wasn't worth it to me to spend an hour trying to figure out the regular expression I needed. (And you don't need to tell me in this case, I got the answer I needed.) And I'll note I have used regular expressions several times in the past couple of months (it's a memory and not intellectual problem), but, again, it just takes me too long to compose them properly unless I really need them.
 

rconn

Administrator
Staff member
May 14, 2008
12,367
150
Well it turns out that a question mark matches a null (i.e., missing) character, which I had never realized before. But even given that, why does a pattern of "???.????" match a file named just "a"?

Microsoft's rules, not mine. A ? may match a single character, or none if the next char is a '.' or the end of the filename (or extension).
 
Similar threads
Thread starter Title Forum Replies Date
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
R FUNCTION to count NUMBER of files matching a pattern and specific length/not length Support 4
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
P Copying files in subdirectories Support 9
C WAD VIEW print multiple files - switches fail Support 10
MikeBaas How to? SELECT: exclude files / display prompt Support 2
Phileosophos WAD Can't rename files in subfolders Support 1
nickles WAD del unable to delete files ending in "." Support 18
P Rename files with ampersand in the name Support 1
C Touch command — I Need to touch matching files in another directory. Support 5
S iftp copying pgp files from ftp is not working Support 11
M Fixed Cannot use the "Browse..." function in "Find files/text" dialogbox Support 2
fromano How to? Everything finding directories with 2 or more files in them Support 3
vefatica Empty .watch files saved Support 0

Similar threads