See if a file name matches extended range.

  • This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.
#1
How would I see if a file matches:

"*.jpgMA[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]_[0-9][0-9][0-9].[0-9][0-9][0-9]"

Looked at @wild but that does not fit... Thank you!
 

samintz

Scott Mintz
May 20, 2008
1,204
11
Solon, OH, USA
#5
Can't you change the grouping instead?
Code:
do fn in *.jpgMA[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]_[0-9][0-9][0-9].[0-9][0-9][0-9] (move "%fn" destination....)
 

samintz

Scott Mintz
May 20, 2008
1,204
11
Solon, OH, USA
#9
The expression I posted matches your wildcard filename. But if you want to play with regular expressions use the regex dialog. Ctrl+F7 or REGEX at the prompt.
upload_2017-7-24_16-51-54.png
 
Jul 6, 2008
241
3
#10
I know TCC/TCMD has a regex analysier / tester - but any documentation on constructing one?

Also thank you very much @samintz
Open the Tcmd/TCC Help file
search for "@regex"
under the @regex help there is a link to "Regular Expression Syntax"
.OR.
search for regular expression syntax
scroll down in the Select topic: window and choose Take Command/TCC Regular Express....

When I do this search the 6th topic is what I am looking for. I added this to my Favorites tab for future reference.

This should assist you in constructing a regular expression.

You could also try: "\w\.jpgMA\d{8}_\d{3}\.\d{3}" assuming the name before the 1st '.' has no special characters. The numbers are inside curly brackets.

There are obviously other ways to construct a Regex that only requires the filename with any combo of digits before and/or after the underscore "_". But based on what I understand from the OP the above should work.
 
#13
Regex defaults to case sensitive unless you wrap it in a group and add the ignore case option.
Code:
\w\.jpg(?i:MA)\d{8}_\d{3}\.\d{3}
Edit: See 7. Extended groups in the Regular Expression Syntax of the help file.

Edit 2: You can also precede the specific section (or entire expression) with the option to apply it to all following text without enclosing the desired text within the group. You can then turn ignore case off again.
Code:
\w\.jpg(?i)MA\d{8}_\d{3}\.\d{3}
\w\.jpg(?i)MA(?-i)\d{8}_\d{3}\.\d{3}
 
Last edited:
Jul 6, 2008
241
3
#14
Looking over the CHM reg exp help - I don't see a way to test if the MA are both uppercase?
The way the Regex is currently written means MA is uppercase.
Did you try using lower case letters, say Ma, is your file name. If you do the current Regex shouldn't match foo.jpgMa..... since the expression is specific to MA, all caps.

If you need to match MA, Ma, ma, or mA then add (?i), meaning case insensitive, to the Regx before the MA string.
Example: Regex \w\.jpg(?i)ma\d{8}_\d{3}\.\d{3} will match foo.jpgmA12345678_123.123

BTW, this was not in the TCC syntax docs. Found this info on-line somewhere. :happy:

Ah! didn't see that until JohnQSmith pointed it out. Thanks.