Link to home
Start Free TrialLog in
Avatar of Darius
DariusFlag for Lithuania

asked on

How to rename multiple files with their first 19 characters

Hi guys,

I would like to rename multiple files by replacing the name by their first 19 characters of their old name.
Can you please assist.

Orginal file naming:
0000000000000376279.xml.3be03b33b7fd403bb03fe27fd1167ffc.error
0000000000000376280.xml.7c157a6cecf644cf934e919292339904.error
0000000000000376281.xml.80d7062d6cbc4c689d7c82c1e6ec35c7.error
. . .
. . .

I want to achieve:
0000000000000376279.xml
0000000000000376280.xml
0000000000000376281.xml
. . .

script used in CMD doesn't work
exception: command is incorrect

ren -n 's/(.{19}).*(\.error)$' *.xml

Open in new window


Thank you
Darius
SOLUTION
Avatar of Hello There
Hello There

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Darius

ASKER

Thank you all for assistance...

Thanks to Hello There for advice to use Powershell.

Thanks oBdA. Code working successfully.

Thank you Bill for answer to my question.