Windows scripting: list files not matching a pattern

前端 未结 3 1730
一生所求
一生所求 2021-01-15 13:31

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\\         


        
3条回答
  •  时光取名叫无心
    2021-01-15 14:07

    An alternative, in case of using a xcopy command instead of echo is using the option /exclude. For instance:

    forfiles /P C:\myFolder\ /M ^[abc]* /S /C "CMD /C xcopy @path %myDestinationFolder% /exclude:abc*"
    

    Also, if you´re using PowerShell, another option is the operator -match.

提交回复
热议问题