#1 18 Jan 2007 17:53

Garbzuk
Member
Registered: 18 Jan 2007
Posts: 1

cmd : renaming a file - anyone clever enough to do this?

Hello,

I hope someone can help me.

I want to write a command which i can run as a batch file in order to bulk rename files.

The task at hand is this:  I have a selection of pdf files, named as follows

XXXXX-1000_ABC.PDF
XXXXX-1001_ABC.PDF
XXXXX-1002_ABC.PDF etc

and I want to rename them as follows:

1000.pdf
1001.pdf
1002.pdf

The logic i guess is search for the '-', and rename as the following 4 digits, removing all other text?

Im sure someone could do this and if so I would be very impressed, and grateful, if they could help me.

Kind Regards,
Martin

Offline

#2 18 Jan 2007 19:54

Simon Sheppard
Super Administrator
Registered: 27 Aug 2005
Posts: 1,031
Website

Re: cmd : renaming a file - anyone clever enough to do this?

untested! - something like..

for /f "tokens=1,2,3 delims=-_." %%G in (*.PDF) do ECHO ren %%G-%%H_%%I.PDF %%H.PDF

Offline

Board footer

Powered by FluxBB