Link to home
Start Free TrialLog in
Avatar of fwecoadmin
fwecoadmin

asked on

Batch renaming

I have a bunch of files that are in this format with these four extensions:

1012_A1.DXF
1-PST-16_A1.sldasm
2619_A1.slddrw
4672_A1.sldprt

The _A1 part needs to be removed. It can be any number after the 'A', but sometimes there is no number afterwards, and sometimes instead of A it's B, C, D, E, or F.

I'm not sure if this can be done with a batch file. They key character to look for is the underscore.

I'm not sure if this can all be done in one batch file, but that would be ideal. It doesn't really matter though, there could be a different batch for every letter. Any and all help is appreciated.
Avatar of squirrelrevolution
squirrelrevolution

You may not be able to do the string manipulation in dos, but here are some ideas to try.
You can use the rename command like this:

rename 4672??1.sldprt 46721.sldprt

That will rename the file 4672_A1 to 46721.sldprt

If you have a list of the file names, and what they should be, you could write a loop file that would loop through them all and rename them.

The loop file would look something like this

@ECHO OFF
for /F %%u  %%o IN (users.txt) do loop.bat %%u %%o

Then loop.bat would look like this

rename %1 %2

Avatar of fwecoadmin

ASKER

It's about 20,000-25,000 files that need to be renamed.

That could work, but I really don't want to have to make a list of all the files.
ASKER CERTIFIED SOLUTION
Avatar of Adam314
Adam314

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
Instead of using batch files u can use the following software “Lupas Rename 2000” it is smart enough to solve your problem.
Adam314, it works great. Thanks a ton! Full points to you.

MahmoudAbdElSattar, we did try some software already and didn't have any luck. I bet the software you mentioned is more robust, but we want to be able to do this in the future from many machine without having to install any software, hense the request for a batch. Thank you for the suggestion though.