REMOVE third word of every file name in PowerShell

Hello everyone,

I need to remove the third word or pattern from every file name in multiple files within multiple folders. The third word could be three or four characters and is the word after the second space from the beginning of the file name. Below is an example:

File names:

ABC 123456-654321 001 Filename1.pdf
ABC 456124-456812 002a Filename2.pdf
ABC 456412-454845 003b Filename3.pdf

Desired result:

ABC 123456-654321 Filename1.pdf
ABC 456124-456812 Filename2.pdf
ABC 456412-454845 Filename3.pdf

Can someone help me with this, please?

THANK YOU

CDiaz,
Welcome to the forum. :wave:t4:

This forum is for scripting questions rather than script requests. We do not write customized and ready to use scripts or solutions on request.

We actually expect you to make an own attempt at the first place to get your task done or to solve your problem. If you have done so already please document here what exactly you have done and show your code. Then we probably might be able to help you step further.

Regardless of that - what you asked for is a very common task and has been asked thousand times already and has been answered thousand times already. You don’t have to re-invent the wheel again. Just use your prefered internet search engine to search for examples you can adapt to your particular needs.

You may simply use the subject you used here as your search term:
https://www.google.com/search?q=REMOVE+third+word+of+every+file+name+in+PowerShell

And as a hint … since your file names seems to have a well defined structure you could use this and split them into the individual parts and just re-join them without the unwanted part. :wink: