Rename question

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
born2achieve
Posts: 51
Joined: 16 Nov 2014 20:28

Rename question

#1 Post by born2achieve » 09 Dec 2016 12:09

I have bat file and i need to rename files in the folder of one server from another server.

Below the sample i tried and didn't work.

Code: Select all

Ren "\\178.70.140.230\Development\Company\*.txt" "*.bak"

but it's not changing the extension Any suggestion please how to achieve this.

Squashman
Expert
Posts: 4471
Joined: 23 Dec 2011 13:59

Re: Rename question

#2 Post by Squashman » 09 Dec 2016 12:17

Use the FOR command to iterate through the list of files and then do the rename.

Just like we showed you in this question.
viewtopic.php?f=3&t=6486#p41489

ShadowThief
Expert
Posts: 1163
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: Rename question

#3 Post by ShadowThief » 09 Dec 2016 13:01

Weird; ren *.txt *.bak should totally work.

Try

Code: Select all

pushd "\\178.70.140.230\Development\Company\"
ren *.txt *.bak
popd

Squashman
Expert
Posts: 4471
Joined: 23 Dec 2011 13:59

Re: Rename question

#4 Post by Squashman » 09 Dec 2016 13:22

born2achieve wrote:I have bat file and i need to rename files in the folder of one server from another server.

Below the sample i tried and didn't work.

Code: Select all

Ren "\\178.70.140.230\Development\Company\*.txt" "*.bak"

but it's not changing the extension Any suggestion please how to achieve this.


I tested this and it worked.

Code: Select all

ren "\\Server\Share\Squashman\rename\*.txt" *.bak

Post Reply