list files with first char within specific range

3

I need to list all files that have first char within a specific range.

If I use Powershell I can do this with

gci [a-c]*

How can I do it from command line?

nick rulez

Posted 2011-05-22T09:46:25.760

Reputation: 285

Answers

4

You may use the following command:

dir /b | findstr /R "^[a-c].*"

Jack Shainsky

Posted 2011-05-22T09:46:25.760

Reputation: 470

Thank you very much. It's perfect. :) I can use even different ranges. ^[a-c|e-h].*". Thanks again. – nick rulez – 2011-05-22T11:47:39.360

Can you explain me why it's necessary the dot after ]? – nick rulez – 2011-05-22T11:49:42.383

This is a regular expression meaning "anything that starts from a-c range followed by zero or more of any characters (the dot)". I'm used to specifying the regular expressions that way, but actually findstr util doesn't require using the full syntax here, so you may omit the dot and the asterisk. – Jack Shainsky – 2011-05-22T21:00:49.417