In Windows 7 command prompt, I´d like to list all files of a folder which name does not start with abc. I have tried:
forfiles /P C:\myFolder\ /M ^[abc]* /S /C "CMD /C echo @file"
Where is my error?
Many thanks.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Looking at
forfiles /?:which strongly suggests
forfilesdoesn’t support regular expressions, just normal Cmd/Windows wildcards.On Windows 7 this can easily be achieved in PowerShell:
(That performs a case-insensitive regular expression match, which doesn’t matter in the case of Windows filenames.)
NB. Assuming you want files not starting
ABC, which isn’t what your (attempted) regular expression says (any filename starting something that isn’ta,borc).