The script you found unconditionally renames all items to filename{sequence number from 1}.jpg from your current directory.
Keep in mind that Rename or Move commands can be very destructive, especially when you don't exactly know what the code is.
I change the code to be safer for you as this:
Get-Item "2017-0~1.*" | ForEach-Object {
$newName = $_.basename + $_.Extension.replace(".", "_") + ".jpg"
Write-Host "rename-item" $_ $newName
# rename-item $_ $newName
}
The code gets items named "2017-0~.*" in the current directory. For each item, rename the item by appending the extension ".jpg" to the end while the original extension dot and extension is changed to underscore and extension e.g. ".001" to "_001". In this case you can know what the original file name was.
Note that the real action is commented.
To execute the code:
> cd c:\to\your\directory
C:\to\your\directory> powershell
PS C:\to\your\directory>
Paste the code
PS C:\to\your\directory> Get-Item "2017-0~1.*" | ForEach-Object {
>>
>> $newName = $_.basename + $_.Extension.replace(".", "_") + ".jpg"
>> Write-Host "rename-item" $_ $newName
>> # rename-item $_ $newName
>> }
>>
PS C:\to\your\directory> exit
C:\to\your\directory>
$i = 1 ; gci "C:\pathToFolder" | rni $_ -newname ("filename" + $i + ".jpg") ; $i++
save this in a script.ps1 file and right click it and "execute with powershell" change filename and .xy to the name and extension you want. change C:\pathtofolder to the folderpath where your files are