question

PumpkinPants-3941 avatar image
0 Votes"
PumpkinPants-3941 asked PumpkinPants-3941 commented

Wildcard behavior in renaming multiple files

I have been trying to rename files that are listed below

E01-pHi10PAAC--62144D67--1-.txt
E02-pHi10PAAC--62144D67--1-.txt
E03-pHi10PAAC--62144D67--1-.txt
...etc

using command line
D:\PATH> dir | Rename-Item -NewName {$_ -replace "pHi*",""}

So my intention is to delete whatever after "pHi" in the file names

But the problem is that when I type the command and run it, it only delete "pHi"
I just wonder if I am doing anything wrong or if there is any case wildcard is not accepted

Thank you ahead!

windows-forms
· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Oh I see I will try
Is there anywhere I can learn those syntaxes?


0 Votes 0 ·

Thank you so much!

0 Votes 0 ·

1 Answer

Viorel-1 avatar image
0 Votes"
Viorel-1 answered

If you need names like E01-pHi.txt, then try one of solutions:

dir | Rename-Item -NewName {$_ -replace "pHi[^.]+","pHi"}


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.