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
moving files across networks
Moderator: DosItHelp
Re: moving files across networks
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\
copy \\192.168.2.100\E$\data\jack\datetime\*.txt \\192.168.2.101\E$\data\jack\datetime\
Re: moving files across networks
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
Re: moving files across networks
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.SIMMS7400 wrote: ↑07 Dec 2017 09:35Run 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
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.