Help renaming files

Job ID: 36916686

Budget: $10 – $30 USD

Hi, I need help to rename a bunch of files in a set of folders without having to do it manually... Here is a sample of what I have:

Directory of C:\Test

19/07/2023 17:53 <DIR> .
16/07/2023 15:27 3,387,292 D10-KTA-00-B11-DR-A-8500.dwg_Ground Floor Area Plan_Tender_1.dwg
16/07/2023 15:27 2,533,255 D10-KTA-01-B11-DR-A-8501.dwg_Level 1 Area Plan_Tender_1.dwg
16/07/2023 15:27 3,038,317 D10-KTA-02-B11-DR-A-8502.dwg_Level 2 Area Plan_Tender_1.dwg
16/07/2023 15:27 2,457,368 D10-KTA-B11-00-DR-A-1201.dwg_Ground Floor Fire Strategy_Tender_2.dwg
16/07/2023 15:27 714,308 D10-KTA-B11-00-DR-A-1201.pdf_Ground Floor Fire Strategy_Tender_3.pdf
16/07/2023 15:27 4,566,196 D10-KTA-B11-00-DR-A-2001.dwg_Ground Floor GA_Tender_2.dwg
16/07/2023 15:27 1,199,556 D10-KTA-B11-00-DR-A-2001.pdf_Ground Floor GA_Tender_2.pdf
16/07/2023 15:27 5,525,958 D10-KTA-B11-00-DR-A-2030.dwg_Airtightness Plan Ground Floor - Sheet 1 of 3_Tender_1.dwg
16/07/2023 15:27 1,049,106 D10-KTA-B11-00-DR-A-2030.pdf_Airtightness Plan Ground Floor - Sheet 1 of 3_Tender_1.pdf
16/07/2023 15:27 6,472,496 D10-KTA-B11-00-DR-A-2060.dwg_Radon Sump Layout Plan_Tender_1.dwg
16/07/2023 15:27 1,213,914 D10-KTA-B11-00-DR-A-2060.pdf_Radon Sump Layout Plan_Tender_1.pdf
16/07/2023 15:27 194,390 D10-KTA-B11-00-DR-A-2070.dwg_Slab Edge Insulation Plan_Tender_1.dwg
16/07/2023 15:27 180,236 D10-KTA-B11-00-DR-A-2070.pdf_Slab Edge Insulation Plan_Tender_1.pdf
16/07/2023 15:27 2,280,673 D10-KTA-B11-00-DR-A-2080.dwg_Ground Floor Construction Phasing Plan_Tender_1.dwg
16/07/2023 15:27 546,481 D10-KTA-B11-00-DR-A-2080.pdf_Ground Floor Construction Phasing Plan_Tender_1.pdf
16/07/2023 15:27 4,543,277 D10-KTA-B11-00-DR-A-2090.dwg_Signage Locations - Ground Floor_Tender_1.dwg
16/07/2023 15:27 1,063,268 D10-KTA-B11-00-DR-A-2090.pdf_Signage Locations - Ground Floor_Tender_1.pdf
16/07/2023 15:27 1,025,671 D10-KTA-B11-00-DR-A-2101.dwg_Reflected Ceiling Plan - Ground Floor_Tender_2.dwg
16/07/2023 15:27 427,817 D10-KTA-B11-00-DR-A-2101.pdf_Reflected Ceiling Plan - Ground Floor_Tender_2.pdf
16/07/2023 15:27 743,750 D10-KTA-B11-00-DR-A-2102.dwg_Reflected Ceiling Plan - Level 1_Tender_2.dwg
20 File(s) 43,163,329 bytes
1 Dir(s) 342,952,910,848 bytes free

I need a script to recursively run through these folders and rename the files to remove the text between the last character before the first period and the second period. I.e:

Input: D10-KTA-B11-00-DR-A-2102.dwg_Reflected Ceiling Plan - Level 1_Tender_2.dwg
Output: D10-KTA-B11-00-DR-A-2102.dwg

It needs to work for all files, regardless of extension.
Related categories: Powershell Scripting