Let's say you had 4 files...
- Filename.043.-2854.exe
- Filename.044.-2123.exe
- Filename.045.-3518.exe
- Filename.046.-6518.jpg
...but you want the ones ending in ".exe" to look like this...
- Filename-2854.exe
- Filename-2123.exe
- Filename-3518.exe
- Filename.046.-6518.jpg
By using the following in Powershell, you can do that.
Get-ChildItem -Path $directory/to/files -Filter '*.exe' | Rename-Item -NewName { $_.Name -replace '.\d{4}' }
Notice file #4 wasn't changed. That is because we filtered by extension so that only the files ending in ".exe" are modified.