Timeline for Powershell rename-item using RegEx for filename irregular pattern
Current License: CC BY-SA 4.0
7 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Nov 2, 2023 at 21:00 | vote | accept | Jeff Taylor | ||
Nov 2, 2023 at 20:58 | comment | added | Jeff Taylor |
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+)?\.?[- ]*')}
|
|
Nov 1, 2023 at 19:01 | comment | added | Toto |
@JeffTaylor: Could you give some examples that don't work? Probably change the last space with [- ]*
|
|
Nov 1, 2023 at 18:21 | comment | added | Jeff Taylor | 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. | |
Nov 1, 2023 at 17:06 | comment | added | Toto | @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. | |
Nov 1, 2023 at 16:27 | comment | added | Jeff Taylor | 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 | |
Nov 1, 2023 at 12:53 | history | answered | Toto | CC BY-SA 4.0 |