Downloading empty folder when using filemask

Advertisement

tkennedy
Joined:
Posts:
11

Downloading empty folder when using filemask

I am using the following few lines in my Powershell script to retreive files according to a file mask.

$GetFileMaskString = "SLEXTRACT*.PGP; MCEXTR*.PGP"

# Use the $transferoptions file mask property for the file mask
$transferoptions.FileMask = $GetFileMaskString

# Download the files according to the file mask stored in transferoptions
$Session.GetFiles("$ServerPath", "$DLPATH", $false, $transferoptions).Check()    

This does successfully download the files, but there is an empty directory above the files on the server, and when I use the file mask, this empty folder gets downloaded also. For example:

FTP Server
----------
EMPTY_FOLDER
SLEXTRACT20131203.PGP
MCEXTR20131203.PGP

When the download is complete, I have successfully downloaded.

EMPTY_FOLDER
SLEXTRACT20131203.PGP
MCEXTR20131203.PGP

How can I prevent this empty folder from being downloaded as well?

##
WinSCP Version 5.1.4 (Build 3020) (OS 6.1.7601 Service Pack 1)
Windows Server 2008 R2 Enterprise
Using SFTP Protocol
.NET Assembly from Powershell

Reply with quote

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

Re: Downloading empty folder when using filemask

There is no way to exclude empty folders from transfer.
_________________
Martin Prikryl

Reply with quote

Advertisement

You can post new topics in this forum