Computing.Net > Forums > Windows NT > A batch file for rename

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.

A batch file for rename

Reply to Message Icon

Name: gohk
Date: August 23, 2005 at 22:17:05 Pacific
OS: NT
CPU/Ram: 128MB
Comment:

I would like to rename numbers of files frome the name abc123.txt, abc456.txt ... to 123.txt, 456.txt ...
So how can I trim the file name?
Thank you



Sponsored Link
Ads by Google

Response Number 1
Name: uli_glueck
Date: August 24, 2005 at 01:15:05 Pacific
Reply:

Take the filename in a variable
for example %filename%

(You can do the whole directory in a for loop.)

echo %filename:~3%

will give out the string from the 4th character.

hope this helps
uli

(123.txt instead of abc123.txt)


0

Response Number 2
Name: Mechanix2Go
Date: August 28, 2005 at 04:24:42 Pacific
Reply:

Try this:

:: abc.bat
@echo off

:main
for %%F in (abc*.txt) do call :renamer %%F
goto :eof

:renamer
set old=%1
ren %1 %old:~3,9%
:: end

M2


If at first you don't succeed, you're about average.


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 Windows NT Forum Home


Sponsored links

Ads by Google


Results for: A batch file for rename

using a batch file to add users for NT4 www.computing.net/answers/windows-nt/using-a-batch-file-to-add-users-for-nt4/3869.html

Deleting a batch file www.computing.net/answers/windows-nt/deleting-a-batch-file/18443.html

RE: using a batch file with pullmail www.computing.net/answers/windows-nt/re-using-a-batch-file-with-pullmail/7351.html