Hi I have a set of files in a folder (windows 10) that are named something like this:
asfdjlaksjfdi09908jfakl.part1.rar
aabdjkhihsdjkf.part2.rar
sdjklufia9798uiownlnsadkfasdFASDFrwe34342.part3.rar
... etc
The bit before the first .
is of variable length and is basically just gibberish.
I want to quickly be able to change the everything before the first .
to the same name it doesn't matter what that is so for example I want the above file names to be:
file.part1.rar
file.part2.rar
file.part3.rar
... etc
I have seen some powershell scripts to find and replace but I don't know how to do find and replace only up until the first .
.
Is this even possible. From some googling I think this can be done with something called regular expressions but I don't have a clue.
What I have tried so far:
So I got the following which works for find and replace but I don't know how to change the find to work for everything up to the first .
with regex.
ls *.rar | Rename-Item -NewName {$_.name -replace "asfdjlaksjfdi09908jfakl","file"}
Basically I just need to change the asfdjlaksjfdi09908jfakl
to be a regex that just replaces everything up until the first .
Can anyone help me with a quick script?
Thanks!!!