moving files across networks

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
joe
Posts: 35
Joined: 06 Sep 2017 07:56

moving files across networks

#1 Post by joe » 07 Dec 2017 06:08

Hi all

I have a few hundreds of .txt files.

now my question is .. how do I move all of these over to a folder on a different machine connected by a LAN Network.

\\192.168.2.100\ e:\data\jack\datetime\*.txt (source files on machine)

\\192.168.2.101 e:\data\jack\datetime\ (target machine)
the LAN network is 1gbe
please help

thanx in advance

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

Re: moving files across networks

#2 Post by Squashman » 07 Dec 2017 09:32

Assuming you have the proper permissions you can use the Administrative share to copy the files.

copy \\192.168.2.100\E$\data\jack\datetime\*.txt \\192.168.2.101\E$\data\jack\datetime\

SIMMS7400
Posts: 546
Joined: 07 Jan 2016 07:47

Re: moving files across networks

#3 Post by SIMMS7400 » 07 Dec 2017 09:35

Run this and take out the ECHO once you can confirm it's working as expected:

Code: Select all

@ECHO OFF

FOR %%F IN ( "*.txt" ) DO (
	ECHO MOVE /Y "\\192.168.2.100\E$\data\jack\datetime\%%~F" "\\192.168.2.101\E$\data\jack\datetime"
)
PAUSE

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

Re: moving files across networks

#4 Post by Squashman » 07 Dec 2017 10:01

SIMMS7400 wrote:
07 Dec 2017 09:35
Run this and take out the ECHO once you can confirm it's working as expected:

Code: Select all

@ECHO OFF

FOR %%F IN ( "*.txt" ) DO (
	ECHO MOVE /Y "\\192.168.2.100\E$\data\jack\datetime\%%~F" "\\192.168.2.101\E$\data\jack\datetime"
)
PAUSE
Some caveats to your code. You are assuming that they are running this batch file from E:\data\jack\datetime\ on the computer 192.168.2.100. If that was the case then you would not need to specify the UNC path with the Administrative share. You would just use the FOR variable by itself.

The code can still fail after the echo is removed because they may not have the proper permissions to the folders remotely or the Administrative shares can be disabled.

There is not need to use a FOR command because the MOVE, COPY, XCOPY and ROBOCOPY all accept wildcards as part of the file specification.

Post Reply