Click here for important information about

Batch - Rename/insert text from a file

Microsoft Windows xp professional w/serv...
January 13, 2010 at 04:15:27
Specs: Windows XP
Hello helpful people.

I have an idea that i think will work with some batch script, but have NO idea how to
program it.
So ANY help will be greatly appreciated!


I have a file named version.txt
Version.txt have 1 line of text containing a version number. ex. client-

I want to use batch to actually change the name "version.txt" to *myIPnumber-client-".

Then upload it to an FTP server (This part i already got).

The whole point is....

1.I have a couple of servers which i have sceduled to restart a running service, the
service will check for update after restart.
2.I need to know which server have successfully updated to the newest version.
3.With all the "newly" renamed myIPnumber-client- files. I can then
easily see which one of the 50 servers failed to update.
4. The best would be to have yet ANOTHER batch file to actually Copy all the file
names and put it into a csv file, then i can write a webpage to display it with some
fancy design :P

Thanks for any help in advance.


See More: Batch - Rename/insert text from a file

January 13, 2010 at 04:37:10
Where dos the IP come from?

Helping others achieve escape felicity


Report •

January 13, 2010 at 05:28:39
The IP comes is the localhost IP.

and or its also in another file.

Any variable to display localhost ip? ie ?

Thanks for the help Mechanix2Go

Report •

January 13, 2010 at 15:54:30
several commands can give localmachine ip's given the machine's name (hostname.exe), but you need to make sure it's the right NIC (the one that will be used for ftp, i think):ipconfig, ping, nbtstat, tracert.

open, read then rename:
@echo off & setlocal
:: supply code to extract ip address into file, or get it directly
:: from the supplying command output using "find" etc.
:: f/e: for /f "skip=xx tokens=* delims=." %%c in ('ipconfig') do (
:: set ipaddr=%%c this only example, won't work as given!
for /f %%a in (ip) do set ipaddr=%%a
for /f %%b in (version.txt) do set xx=%%b
ren version.txt %ipaddr%-%xx%

Report •

Related Solutions

January 13, 2010 at 21:07:52
@echo off & setLocal EnableDELAYedeXpansion

set /p i=<IPfile
set /p v=<version.txt
ren version.txt !i!-!v!.txt

Helping others achieve escape felicity


Report •

January 14, 2010 at 00:28:15
Thanks for the help Mechanix2Go and nbrane!

Works like a charm!!

Report •

Ask Question