batch file to copy files from local to remote

July 2, 2011 at 03:53:07
Specs: Windows Vista
Hi, I'm working on a batch to copy files from local directory to remote server, requirements are as follows:
1. copying dirctory structure to remote, if new directory gets created in local that should reflect in remote without overwriting the existing ones.
2. & here is a detailed scope, what I'm looking for:

Local Side:
+myData
------------SiteA
------------SiteB
------------SiteC and so on. Each Site directory contains
abc_abc-IN-abc.txt
abc_abc-OUT-abc.txt
abc_abc-IN-abc.log
abc_abc-OUT-abc.log

Now they have to be copied on remote side (or on local itself in myData2) as:
+someDir (or lets say myData2)
--------------SiteA
-----------------------dd-mm-yy (directory has to be created using the date input)
-------------------------------------subDir (all *.txt will be copied here)
--------------------------------------IN ( all log files containing string IN will be copied)
------------------------------------ Out ( all log files containing string OUT will be copied)

--------------SiteB
--------------SiteC
--------------and so on.

It would be a great support if someone will help me on what switches or if/for conditions I've to use.
Thanks in advance.
Sidd


See More: batch file to copy files from local to remote

Report •

#1
July 2, 2011 at 09:33:00
If exist will test for filenames in a directory.

Report •

#2
July 2, 2011 at 11:16:36
I didn't got you..

Report •

#3
July 2, 2011 at 18:52:53
Now I know you have not looked at the batch file command list, let alone the arguments that they will accept.
How do you plan to get this done if you have not started? Post what you have. Maybe you'll get a suggestion.

Report •

Related Solutions

#4
July 4, 2011 at 23:36:52
Hi
This is wt I've made

@echo off
:START
@echo on
@echo This batch file will backup files to remote directory.

:ASK_TO_CONTINUE
@set Continue_Flag=
@set /P Continue_Flag=Do you want to continue? (y/n):%=%
@if /I "%Continue_Flag%"=="Y" goto :dirStructure
@if /I "%Continue_Flag%"=="N" goto :EOF
@goto :ASK_TO_CONTINUE

:dirStructure
@echo off
cd %UserProfile%\Desktop\Ankush
md %UserProfile%\Desktop\Ankush\LTE.tmp
cd %UserProfile%\Desktop\Ankush\LTE.tmp
cls

@echo on
@set /p date=Enter Date(DDMMYYYY): %=%
@echo off

for /F "delims=~" %%f in (%UserProfile%\Desktop\Ankush\sites.txt) DO MD "%%f"
for /F "delims=~" %%f in (%UserProfile%\Desktop\Ankush\sites.txt) DO MD "%%f\%date%\1.driveLogs"
for /F "delims=~" %%f in (%UserProfile%\Desktop\Ankush\sites.txt) DO MD "%%f\%date%\2.output"
for /F "delims=~" %%f in (%UserProfile%\Desktop\Ankush\sites.txt) DO MD "%%f\%date%\3.siteAnalysis"
for /F "delims=~" %%f in (%UserProfile%\Desktop\Ankush\sites.txt) DO MD "%%f\%date%\1.driveLogs\iperf"
for /F "delims=~" %%f in (%UserProfile%\Desktop\Ankush\sites.txt) DO MD "%%f\%date%\1.driveLogs\tcp"
for /F "delims=~" %%f in (%UserProfile%\Desktop\Ankush\sites.txt) DO MD "%%f\%date%\1.driveLogs\udp"
for /F "delims=~" %%f in (%UserProfile%\Desktop\Ankush\sites.txt) DO MD "%%f\%date%\1.driveLogs\handover"
cls

@echo The sub-directories have been created.
@echo Now the files will be copied to respective directories.
@echo.

:ASK_TO_CONTINUE2
@set Continue_Flag=
@set /P Continue_Flag=Do you want to continue? (y/n):%=%
@if /I "%Continue_Flag%"=="Y" goto :startCopying
@if /I "%Continue_Flag%"=="N" goto :EOF
@goto :ASK_TO_CONTINUE2

:startCopying

??

Now, I want all the *.txt from LTE\siteA directory to LTE.tmp\siteA\%date%\1.driveLogs\iperf
& same for all other directories like siteB, siteC and so on.

Pls help on this. Thanks!


Report •

Ask Question