How to exclude directories during a get

Advertisement

KTGOPS1
Guest

How to exclude directories during a get

I have automated a sftp file and directory download process through a batch file. There is one directory one the server I do not need to download but I can not figure out how to exclude that directory. I could download it and delete it but it is a huge folder that doesn't need to be pulled down. How can I exclude the folder. Here is my batch file now.

I am using winscp version 5.11.2
This is running on Windows Server 2012 R2

There is a folder in this directory on the server I should not download. /home/customer/data/%year%/%month%/%day%

@echo off

Set CurrentDate=%date:~4,2%-%date:~7,2%-%date:~10,4%
Set Year=%date:~10,4%
Set Month=%date:~4,2%
Set Day=%date:~7,2%

if not exist D:\backups\Software\%CurrentDate% md D:\backups\Software\%CurrentDate%

Echo option echo off>d:\test\downloadscript.txt
Echo option batch on>>d:\test\downloadscript.txt
Echo option confirm off>>d:\test\downloadscript.txt
Echo open sftp://user:password@10.10.10.10>>d:\test\downloadscript.txt
Echo lcd "D:\Backups\Software\%CurrentDate%">>d:\test\downloadscript.txt
Echo cd /home/customer/data/%year%/%month%/%day%>>d:\test\downloadscript.txt
Echo get *.*>>d:\test\downloadscript.txt
Echo exit>>d:\test\downloadscript.txt


"C:\Program Files (x86)\WinSCP\Winscp.com" /script=d:\test\downloadscript.txt

C:\Progra~1\7-Zip\7z a -r D:\backups\Software\%currentDate%.7z D:\backups\Software\%CurrentDate%\*

RD /S /Q D:\backups\Software\%currentDate%

del downloadscript.txt

Reply with quote

Advertisement

KTGOPS1
Guest

Re: How to exclude directories during a get

Thank you very much. This worked. Below is what my new txt file looks like. Was not working at first until I had to add the / after the l1. L1 is the folder I was excluding. Works great now. Thanks again.

option echo off
option batch on
option confirm off
open sftp://user:password@10.10.10.10
lcd "D:\Backups\Software\12-07-2017"
cd /home/customer/data/2017/12/07
get *.* -filemask=|/home/customer/data/2017/12/07/l1/
exit

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
27,253
Location:
Prague, Czechia

Re: How to exclude directories during a get

KTGOPS1 wrote:

Was not working at first until I had to add the / after the l1.
That's correct. Note that my exclude path also ends with a slash.

Reply with quote

Advertisement

You can post new topics in this forum