?
Solved

How to rename a file with CMD including the hostname?

Posted on 2015-01-28
3
Medium Priority
?
99 Views
Last Modified: 2015-01-28
Using Batch I want to rename a file as follows

System.txt -> rename to -> system_server1.txt
0
Comment
Question by:acunaara
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 96

Accepted Solution

by:
Lee W, MVP earned 2000 total points
ID: 40575768
Very simple if by hostname you mean computer name:
Ren "system.txt" "%computername%_system.txt"
0
 
LVL 96

Expert Comment

by:Lee W, MVP
ID: 40575775
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"
0
 

Author Closing Comment

by:acunaara
ID: 40575795
Nice Thanks for your prompt response!!
0

Featured Post

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

New Windows 7 Installations take days for Windows-Updates to show up and install. This can easily be fixed. I have finally decided to write an article because this seems to get asked several times a day lately. This Article and the Links apply to…
This article provides a convenient collection of links to Microsoft provided Security Patches for operating systems that have reached their End of Life support cycle. Included operating systems covered by this article are Windows XP,  Windows Server…
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question