How do I re-use my wildcard match?

2019-09-08 05:09发布

There's some advanced file moving that needs to be done with the Windows command prompt; Is it possible to do it with wildcards?

Using regular expressions in UNIX, I could do something like this to find all files that begin with "s" and then do something else with them (echo).

ls s(.*) ; echo Found file \1 , needs to be moved to C:\unicorns\(\1)

I want to do something like that in Windows command prompt:

:: find all files that begin with "s" and then do something else with them (echo)
dir s(*) ; echo Found file \1

1条回答
Evening l夕情丶
2楼-- · 2019-09-08 05:55

Do something like this:

for %%f in (*) do (echo %%f)

This will echo a list of files found in current directory. Find more description here

查看更多
登录 后发表回答