Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

5
  • Hello, I tested that RegEx in Notepad++ it but it only selects the numerical portion of the line, not the characters up to the first Alpha character Commented Nov 1, 2023 at 16:27
  • @JeffTaylor: Have you put a space at the end of the regex? As it's describe in my answer. I also tested in Notepad++ and it works fine, at least for the examples given.
    – Toto
    Commented Nov 1, 2023 at 17:06
  • good catch. I did add one whitespace and that does pickup a few more lines but still not picking up a "-" or additional whitespace leading up to the first alpha character. Commented Nov 1, 2023 at 18:21
  • @JeffTaylor: Could you give some examples that don't work? Probably change the last space with [- ]*
    – Toto
    Commented Nov 1, 2023 at 19:01
  • Yes @Toto that worked perfectly. Thanks for hanging in there to help out. This was my final one-liner: foreach ($file in (get-childitem *.mp3).name) { Rename-Item $file ($file -replace '^\d+(?:-\d+)?\.?[- ]*')} Commented Nov 2, 2023 at 20:58