Computing.Net > Forums > Disk Operating System > Renaming multiple files

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Renaming multiple files

Reply to Message Icon

Name: willwak
Date: September 27, 2004 at 02:35:33 Pacific
OS: win 2000 pro
CPU/Ram: 128
Comment:

I would like help with a dos batch file program that renames multiple filenames of 8 characters long to filenames of 7 characters long without changing the last four characters.
e.g
00070011.rrt should be: BCX0011.rrt
00070012.rrt should be: BCX0012.rrt
00070013.rrt should be: BCX0013.rrt
..and so on.
the script should actually remove the first zero in the filenames as in the example. Thanx in advance



Sponsored Link
Ads by Google

Response Number 1
Name: IVO
Date: September 27, 2004 at 06:33:51 Pacific
Reply:

The following script achieves your wishes:

@Echo Off

For %%A in (%~f1\*.rrt) Do Call :REN %~f1 %%A
GoTo :EOF

:REN
Set File=%~nx2
Ren %~f1\%File% BCX%File:~4%
GoTo :EOF

To run save it as XRen.bat then type XRen Folder_Name where Folder_Name is the directory holdings your rrt files to be renamed (the directory's name must not have embedded spaces).

By the way that is a NT-batch as Win NT/2K/XP have no DOS at all and the prompt is actually the NT-system console while DOS is emulated by NTVDM (DOS Virtual Machine).


0

Response Number 2
Name: IVO
Date: September 27, 2004 at 07:12:55 Pacific
Reply:

Sorry, but after a more deeper test replace

For %%A in (%~f1\*.rrt) Do Call :REN %~f1 %%A

with

For %%A in (%~f1\0*.rrt) Do Call :REN %~f1 %%A

to avoid unwanted side effects.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Disk Operating System Forum Home


Sponsored links

Ads by Google


Results for: Renaming multiple files

Rename multiple Files www.computing.net/answers/dos/rename-multiple-files/14239.html

Renaming Multiple Files www.computing.net/answers/dos/renaming-multiple-files/13297.html

multiple renaming of file www.computing.net/answers/dos/multiple-renaming-of-file/16829.html