Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

In the command prompt, I need a way up rename a file on a remote server. Conceptually, this is what I am looking for:

ren \\servername\folder\file.txt \\servername\folder\file2.txt

Aside from using PSTools, is there a way to do this locally from the C: drive? I think I can also map a network folder to a drive letter and do it that way, but this batch file I am using needs to be usable by everyone and can't require the user to map a drive. If that is the only way then I guess I'll have to go with it.

share|improve this question

1 Answer 1

up vote 11 down vote accepted

Do not use a full path for the second argument. Only the first argument requires a full path. Windows assumes since you are renaming, the file will remain in the same folder as previously specified. It mentions this in the command help at the bottom:

C:\Users\John>ren /?
Renames a file or files.

RENAME [drive:][path]filename1 filename2.
REN [drive:][path]filename1 filename2.

Note that you cannot specify a new drive or path for your destination file.

e.g.:

ren \\servername\folder\file.txt file2.txt

Alternatively you can map a drive letter to the UNC share and then issue a command such as:

ren Z:\file.txt file2.txt
share|improve this answer
    
It works! I can now rename files located on a remote server folder. And to think I actually created a batch file called uncren.bat to copy a file and delete the old like that other guy talked about lol. Thanks. –  oscilatingcretin Aug 31 '11 at 12:41

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.