Click here for important information about

Renaming a file to its hostname

Acer Aspire 5920g
August 2, 2010 at 22:45:26
Specs: Microsoft Windows 7 Professional, 2.201 GHz / 2046 MB
Hi guys how do i rename a file to its host name? For example report.txt will be renamed as reportAndy.txt

Currently this is my script to add date to filename to i want to add hostname inside too..
ren C:\final.txt final%date:~10%-%date:~4,2%-%date:~7,2%%time:~0,2%h%time:~3,2%m%time:~6,2%s%.txt

See More: Renaming a file to its hostname

August 3, 2010 at 18:46:27
If you mean the user? If this is the same as whoever would be logged in to the computer you would use the variable %username%, If that's not what you mean, just let me know.

Report •

August 4, 2010 at 08:53:39
Hmm i want the Full Computer name which is under -> right click my computer -> computer name.. btw is there anyway to put ip address to your filename too??

Report •

August 4, 2010 at 14:59:37
For the computer name, the variable %ComputerName% should do the trick, and for the ip address... you will need to have this in your batch file:

SETLOCAL EnableDelayedExpansion


FOR /f "tokens=2 delims=:" %%a IN (IPCONFIG.txt) DO (
	SET IP=%%a

Then use the variable %IP%

Hope I've helped!

Report •

Related Solutions

August 4, 2010 at 16:20:47
That helped! Helps alot dude:)

Report •

Ask Question