Link to home
Start Free TrialLog in
Avatar of acunaara
acunaara

asked on

How to rename a file with CMD including the hostname?

Using Batch I want to rename a file as follows

System.txt -> rename to -> system_server1.txt
ASKER CERTIFIED SOLUTION
Avatar of Lee W, MVP
Lee W, MVP
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
If you mean hostname (which in generally rare circumstances COULD be different from the computer name) then it's SLIGHTLY more complicated:
for /f %%a in ('hostname') do set Hostname=%%a
ren "system.txt" "%hostname%_system.txt"
Avatar of acunaara
acunaara

ASKER

Nice Thanks for your prompt response!!