Welcome!

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

SignUp Now!

char class wildcard issue when [] in path

When I use [0-9][0-9][0-9] as a wildcard character class in a DIR command, TCC shows a file not found error for an existing file when the file path includes "[something]". Replacing ??? for the character class works around this issue.
If I CD into the folder and DIR again I still get an error message.
Rex, can this be fixed? The work-around I found isn't sufficient for my needs.
Thanks

Versions:
TCC 9.02.157 Windows XP [Version 5.1.2600]
TCC LE 10.00.74 Windows XP [Version 5.1.2600]
Windows XP Pro SP3 English

C:\>touch /C "a [test]\a b "000" d.e f"
9/20/2010 8:46:28.390 C:\a [test]\a b 000 d.e f

C:\>dir "a [test]\a b "[0-9][0-9][0-9]" d.e f"

TCC: (Sys) The system cannot find the file specified.
"C:\a [test]\a b [0-9][0-9][0-9] d.e f"
0 bytes in 0 files and 0 dirs

C:\>dir "a [test]\a b "???" d.e f"

Directory of C:\a [test]\a b ??? d.e f

9/20/2010 11:46 0 a b 000 d.e f
0 bytes in 1 file and 0 dirs

C:\>cd "a [test]"\

C:\a [test]>dir "a b "[0-9][0-9][0-9]" d.e f"

TCC: (Sys) The system cannot find the file specified.
"C:\a [test]\a b [0-9][0-9][0-9] d.e f"
0 bytes in 0 files and 0 dirs

C:\>
 
in path

On Mon, 20 Sep 2010 06:07:11 -0400, Stefano Piccardi <>
wrote:

|C:\a [test]>dir "a b "[0-9][0-9][0-9]" d.e f"
|
|TCC: (Sys) The system cannot find the file specified.
| "C:\a [test]\a b [0-9][0-9][0-9] d.e f"
| 0 bytes in 0 files and 0 dirs

I suspect TCC is seeing that as three file specifications: "a b ",
[0-9][0-9][0-9], and " d.e f" (you can't nest quotes like that).

These work (v10):

Code:
v:\> touch /c "a b 000 d.e f"
2010-09-20 09:28:32.376  V:\a b 000 d.e f

v:\> dir /k /m "a b [0-9][0-9][0-9] d.e f"
2010-09-20  09:28               0  a b 000 d.e f

v:\> v:\> dir /k /m "*[0-9][0-9][0-9]*.e f"
2010-09-20  09:28               0  a b 000 d.e f
 
Re: in path

Thanks but did you try placing the file in a folder with "[something]" in its name? Here it's an essential condition to reproduce this issue.
These work (v10):

Code:
v:\> touch /c "a b 000 d.e f"
2010-09-20 09:28:32.376  V:\a b 000 d.e f

v:\> dir /k /m "a b [0-9][0-9][0-9] d.e f"
2010-09-20  09:28               0  a b 000 d.e f

v:\> v:\> dir /k /m "*[0-9][0-9][0-9]*.e f"
2010-09-20  09:28               0  a b 000 d.e f
Moreover, I can't use any of the * and ? to "make it work". I really need to use just [0-9] repeated a fixed number of times.

Finally, (side issue) I was under the impression that quoting a wildcard turns off its special meaning, at least so it seemed while I was trying to narrow down this issue. I will check again.
 
in path

Use the regex override after the directory path and before the file pattern.

D:\>*dir "a [test]\::a b [0-9][0-9][0-9] d.e f" /k /m
2010-09-20 09:53 0 a b 000 d.e f



On Mon, Sep 20, 2010 at 03:07, Stefano Piccardi <>wrote:


> When I use [0-9][0-9][0-9] as a wildcard character class in a DIR command,
> TCC shows a file not found error for an existing file when the file path
> includes "[something]". Replacing ??? for the character class works around
> this issue.
> If I CD into the folder and DIR again I still get an error message.
> Rex, can this be fixed? The work-around I found isn't sufficient for my
> needs.
> Thanks
>
> Versions:
> TCC 9.02.157 Windows XP [Version 5.1.2600]
> TCC LE 10.00.74 Windows XP [Version 5.1.2600]
> Windows XP Pro SP3 English
>
> C:\>touch /C "a [test]\a b "000" d.e f"
> 9/20/2010 8:46:28.390 C:\a [test]\a b 000 d.e f
>
> C:\>dir "a [test]\a b "[0-9][0-9][0-9]" d.e f"
>
> TCC: (Sys) The system cannot find the file specified.
> "C:\a [test]\a b [0-9][0-9][0-9] d.e f"
> 0 bytes in 0 files and 0 dirs
>
> C:\>dir "a [test]\a b "???" d.e f"
>
> Directory of C:\a [test]\a b ??? d.e f
>
> 9/20/2010 11:46 0 a b 000 d.e f
> 0 bytes in 1 file and 0 dirs
>
> C:\>cd "a [test]"\
>
> C:\a [test]>dir "a b "[0-9][0-9][0-9]" d.e f"
>
> TCC: (Sys) The system cannot find the file specified.
> "C:\a [test]\a b [0-9][0-9][0-9] d.e f"
> 0 bytes in 0 files and 0 dirs
>
> C:\>
>
>
>
>
>



--
Jim Cook
2010 Sundays: 4/4, 6/6, 8/8, 10/10, 12/12 and 5/9, 9/5, 7/11, 11/7.
Next year they're Monday.
 
Re: in path

Use the regex override after the directory path and before the file pattern.

D:\>*dir "a [test]\::a b [0-9][0-9][0-9] d.e f" /k /m
2010-09-20 09:53 0 a b 000 d.e f
Cool, thanks! I wasn't aware I could use regular expressions in filename matching. It seems to work both in TCC 9 and TCCLE 10, and to solve the issue I raised.

It appears that I can place :: anywhere in the filename, and the regex match starts at that point. So in my example I should write
DIR "a [test]\a b ::[0-9][0-9][0-9] d.e f" /k /m

I couldn't find this topic in the help file.

But I found an old post of Vince's which said that regex filename matching is *substring* matching and case-insensitive. So, I need to be careful that I only want the [0-9][0-9][0-9] part to behave like a regex. "::" can be used to enter regex mode, but not to exit it. Is there an "exit regex mode" sequence at all?

I know how to anchor the substring using $ and other regex syntax, I was just wondering how far I can go on the :: syntax alone.
 
Re: in path

Correcting myself. After further testing, apparently I can conclude that :: regex matching works only when :: is at the beginning of a filename, as Jim showed in his post.

This point - coupled with the fact that :: matches substrings - makes using the regex matching rather impractical for my use, because I need to DIR this kind of pattern:
Code:
   DIR "%prefix%[0-9][0-9][0-9]%suffix%"
where prefix and suffix are fixed strings that the user inputs.

I know how to do it with wildcards - if it worked properly in all cases - but doing it with regular expressions is complicated. I would need to escape all regex metacharacters in prefix and suffix to ensure that [0-9] is the only matching part, and anchor start and end of regex pattern like so (untested):
Code:
  SET escaped_prefix=%@XREPLACE[(.),[\1],%prefix%]
  SET escaped_suffix=%@XREPLACE[(.),[\1],%suffix%]
  DIR ::"^%escaped_prefix%[0-9][0-9][0-9]%escaped_suffix%$"
It seems a bit cumbersome. Any other ideas? Thanks.

(@XREPLACE from Vince's 4UTILS plugin)
 
Re: in path

A few less-than-elegant ideas:

1. Don't specify the directory; CD or PUSHD to the desired directory and then pass DIR just the desired wildspec.

2. Don't specify the directory; use DIR /S.

3. Use the SFN for the directory: DIR "A_TEST~1\A B [0-9][0-9][0-9] D.E F"
 
Re: in path

I'm late joining the party here, so I'm sorry if this has already been
mentioned.

Reading this email it seems like you're looking for a pattern that has a
fixed beginning, three decimal digits, then a fixed ending. Why do you
need to escape the prefix and suffix? Do they contain regex metachars?

why couldn't you just search for:

dir ::this_is_prefix\d\d\dthis_is_suffix

-Scott


Stefano Piccardi <> wrote on 09/21/2010 03:08:40 AM:


> Correcting myself. After further testing, apparently I can conclude
> that :: regex matching works only when :: is at the beginning of a
> filename, as Jim showed in his post.
>
> This point - coupled with the fact that :: matches substrings -
> makes using the regex matching rather impractical for my use,
> because I need to DIR this kind of pattern:
>
> Code:
> ---------
> DIR "%prefix%[0-9][0-9][0-9]%suffix%"
> ---------
> where prefix and suffix are fixed strings that the user inputs.
>
> I know how to do it with wildcards - if it worked properly in all
> cases - but doing it with regular expressions is complicated. I
> would need to escape all regex metacharacters in prefix and suffix
> to ensure that [0-9] is the only matching part, and anchor start and
> end of regex pattern like so (untested):
>
> Code:
> ---------
> SET escaped_prefix=%@XREPLACE[(.),[\1],%prefix%]
> SET escaped_suffix=%@XREPLACE[(.),[\1],%suffix%]
> DIR ::"^%escaped_prefix%[0-9][0-9][0-9]%escaped_suffix%$"
> ---------
> It seems a bit cumbersome. Any other ideas? Thanks.
>
> (@XREPLACE from Vince's 4UTILS plugin)
>
>
>
>
 
Re: in path

Thanks. I had already tried #1 and it didn't help. #2 doesn't help either. But #3 magically works! Mysteries of Windows (or TCC, who knows).
Anyhow, prefixing the filename with a SFN path seems to be the way to make DIR correctly match a [0-9] wildcard in the filename when the filepath includes a string like "[something]".

Thank you for your suggestion!

A few less-than-elegant ideas
1. Don't specify the directory; CD or PUSHD to the desired directory and then pass DIR just the desired wildspec.

2. Don't specify the directory; use DIR /S.

3. Use the SFN for the directory: DIR "A_TEST~1\A B [0-9][0-9][0-9] D.E F"
 
Re: in path

I have an old 4DOS alias that I still use named IN.

alias in=`pu %1 %+ %2$ %+ po`

Why does your DIR fail if you CD to the directory first? Also you could
use \d instead of [0-9] for the digit. Then you could escape any brackets
in the path name.

-Scott

Stefano Piccardi <> wrote on 09/22/2010 04:41:15 PM:


> Thanks. I had already tried #1 and it didn't help. #2 doesn't help
> either. But #3 magically works! Mysteries of Windows (or TCC, who
knows).

> Anyhow, prefixing the filename with a SFN path seems to be the way
> to make DIR correctly match a [0-9] wildcard in the filename when
> the filepath includes a string like "[something]".
>
> Thank you for your suggestion!
>
>
> ---Quote (Originally by Charles Dye)---
> A few less-than-elegant ideas
> 1. Don't specify the directory; CD or PUSHD to the desired
> directory and then pass DIR just the desired wildspec.
>
> 2. Don't specify the directory; use DIR /S.
>
> 3. Use the SFN for the directory: DIR "A_TEST~1\A B [0-9][0-9][0-9]
D.E F"

> ---End Quote---
>
>
>
 
Re: in path

Reading this email it seems like you're looking for a pattern that has a
fixed beginning, three decimal digits, then a fixed ending. Why do you
need to escape the prefix and suffix? Do they contain regex metachars?

why couldn't you just search for:

dir ::this_is_prefix\d\d\dthis_is_suffix
I'm writing a batch file. User's input %1 is a filename. The batch file looks for %@NAME[%1][0-9].%@TYPE[%1]. I ran into a TCC issue/quirk/bug/gotcha/whatever whereby DIR bails out with a system error message if the _path_ to the filename includes a string like "[something]". I was looking for ways to work-around this issue, and one suggestion was to use :: regex matching. But :: is _substring_ matching, so I'd need to ensure that %@NAME[%1] and .%@TYPE[%1] are matched as anchored literals.

Luckily Charles suggested specifying the file _path_ in DIR as a SFN, which - quite magically - stops DIR from bailing out. Several other work-arounds I tried didn't help.
 
Re: in path

What does @TYPE do? Is that one of yours or someone's plugin?

I was going to suggest Everything Search but I see you're already a fan.
:)

-Scott




Stefano Piccardi <> wrote on 09/22/2010 05:07:07 PM:


> ---Quote (Originally by samintz)---
> Reading this email it seems like you're looking for a pattern that has a


> fixed beginning, three decimal digits, then a fixed ending. Why do you
> need to escape the prefix and suffix? Do they contain regex metachars?
>
> why couldn't you just search for:
>
> dir ::this_is_prefix\d\d\dthis_is_suffix
> ---End Quote---
> I'm writing a batch file. User's input %1 is a filename. The batch
> file looks for %@NAME[%1][0-9].%@TYPE[%1]. I ran into a TCC
> issue/quirk/bug/gotcha/whatever whereby DIR bails out with a system
> error message if the _path_ to the filename includes a string like
> "[something]". I was looking for ways to work-around this issue, and
> one suggestion was to use :: regex matching. But :: is _substring_
> matching, so I'd need to ensure that %@NAME[%1] and .%@TYPE[%1] are
> matched as anchored literals.
>
> Luckily Charles suggested specifying the file _path_ in DIR as a
> SFN, which - quite magically - stops DIR from bailing out. Several
> other work-arounds I tried didn't help.
>
>
>
>
 
Re: in path

I have an old 4DOS alias that I still use named IN.

alias in=`pu %1 %+ %2$ %+ po`
???
Why does your DIR fail if you CD to the directory first? Also you could
use \d instead of [0-9] for the digit. Then you could escape any brackets
in the path name.
I have no idea why it fails. It just does. And no, I couldn't use \d because I'm not using ::. I use [0-9] as an extended wildcard.

Why does DIR fail with the extended wildcard?
 
Back
Top