0

So, first off, I have seen: Powershell equivalent of Bash Brace Expansion for generating lists/arrays, but that doesn't quite address what I want.

In that case, the author is fine with the expansion being multiple calls to the same command. However, one of my favorite "power user" features of Bash was the below:

mv test{1,2}.md

Which expands nicely into:

mv test1.md test2.md

This was amazing for renaming, copying, or removing related files and all sorts of other things. Does PowerShell have anything like that?

I tried a format string:

mv ("{0}1{1} {0}2{1}" -f "test",".md")

But, not only is that rather cumbersome, it passes the combined format string as one arg to mv.

So, does the shortcut I seek exist in PowerShell? My Google-fu has failed me.

hjc1710
  • 576
  • 4
  • 17
  • `mv test[12].md foo -whatif` – js2010 Jul 15 '20 at 23:19
  • `mv test[12].md foo -whatif` doesn't really do what I want. That will move both `test1.md` and `test2.md` to `foo`. That's useful for renaming two files at once, but not 100% the spirit of the question. – hjc1710 Jul 16 '20 at 22:20
  • Sounds like `{a,b}` is some kind of syntactic sugar in bash. I don't know of an equivalent in PowerShell off the top of my head. It may be possible to write a function but there'd need to be a spec. – Bill_Stewart Jul 21 '20 at 23:05

0 Answers0