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
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.
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??
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: @ECHO OFF SETLOCAL EnableDelayedExpansion IPCONFIG | FIND "IPv4">IPCONFIG.txt FOR /f "tokens=2 delims=:" %%a IN (IPCONFIG.txt) DO ( SET IP=%%a ) DEL IPCONFIG.txtThen use the variable %IP%
Hope I've helped!
That helped! Helps alot dude:)