Rename multi files

I’m having trouble renaming files in PowerShell

Input

24KT1906101001-1
24KT1906101002-2
24KT1906101010-10
24KT1906101016-16
24KT1906101017_19-17
24KT1906101017_18-18
24KT1906101017_19-19
24KT1906101020_21-20
24KT1906101020_21-21

Output
become

24KT1906101001
24KT1906101002
24KT1906101010
24KT1906101016
24KT1906101017
24KT1906101018
24KT1906101019
24KT1906101020
24KT1906101021

Now how to do it in PowerShell, please help

Ari,
Welcome to the forum. :wave:t3:

What kind of trouble do you have exactly?

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 … When you post code, sample data, console output or error messages please format it as code using the preformatted text button ( </> ). Simply place your cursor on an empty line, click the button and paste your code.

Thanks in advance

How to format code in PowerShell.org 1 <---- Click :point_up_2:t4: :wink:

( !! Sometimes the preformatted text button hides behind the settings gear symbol. :wink: )

And last but not least … you don’t have to re-invent the wheel again and again … renaming files is a very basic and common task to do in PowerShell. There are literally thousands of code examples out there you can easily adapt to your own particular needs. So please use your prefered internet search engine to look for suitable code examples.

Bye
Olaf

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.