Topic "Synchronization exluding folder"

Author Message
majestic

Guest


I am trying to sync a remote FTP folder to a local folder using Powershell. The remote FTP folder has a strange directory name that I am trying to exclude using a file mask. I have tried various combinations, but I am always getting the same error:

Error listing directory '/ftp_images/manufacturers/type=dir;sizd=4096;modify=20131010193915;UNIX.mode=0775;UNIX.uid=48;UNIX.gid=48;unique=14g1004d1;'.
Could not retrieve directory listing
Can't change directory to /ftp_images/manufacturers/type=dir;sizd=4096;modify=20131010193915;UNIX.mode=0775;UNIX.uid=48;UNIX.gid=48;unique=14g1004d1;/: No such file or directory

It would appear that WinSCP is trying to list the folder even though I have it excluded in my script and that is throwing the error. Does anyone know how to prevent WinSCP from even trying to list the folder or change to the directory?

Here's my code:
Code:

try
{
# Load WinSCP .NET assembly
Add-Type -Path "C:\Program Files (x86)\WinSCP\WinSCPnet.dll"

# Setup session options
$sessionOptions = New-Object WinSCP.SessionOptions
$sessionOptions.Protocol = [WinSCP.Protocol]::Ftp
$sessionOptions.HostName = "HOST"
$sessionOptions.UserName = "USENAME"
$sessionOptions.Password = "PASSWORD"

$transferOptions = New-Object WinSCP.TransferOptions
$transferOptions.FileMask = "| ftp_images/manufacturers/type=dir;;sizd=4096;;modify=20131010193915;;UNIX.mode=0775;;UNIX.uid=48;;UNIX.gid=48;;unique=14g1004d1;;/"

$session = New-Object WinSCP.Session
$session.SessionLogPath = "D:\winscp.log"
 
      try
      {
      # Progress
      $session.add_FileTransferred( { FileTransferred($_) } )
      
      # Connect
      $session.Open($sessionOptions)
      
      #Sync
      $synchronizationResult = $session.SynchronizeDirectories(
            [WinSCP.SynchronizationMode]::Local, $destfilepath, $sourcefilepath, $False, $transferOptions)

      # Throw on any error
        $synchronizationResult.Check()
      
        # Print results
         foreach ($sync in $synchronizationResult.Transfers)
         {
            Write-Host ("Upload of {0} succeeded" -f $sync.FileName)
            Write-Host "============================================"
         }
      }
      finally
      {
        # Disconnect, clean up
        $session.Dispose()
      }
}
catch [Exception]
{
Write-Host $_.Exception.Message
exit 1
}


Any help would be appreciated. Thank you.
Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24995
Location: Prague, Czechia
There's something strange going on. That's does not look like a directory name, that looks like a directory listing line in MLSx format.

Please attach a full session log file showing the problem (using the latest version of WinSCP).

To generate the session log file, set Session.SessionLogPath. Submit the log with your post as an attachment. Note that passwords and passphrases not stored in the log. You may want to remove other data you consider sensitive though, such as host names, IP addresses, account names or file names (unless they are relevant to the problem). If you do not want to post the log publicly, you can mark the attachment as private.
majestic

Guest


I agree that it looks strange. When I connect using the WinSCP GUI I can see the strange folder in question (image001), but when I connect using FileZilla, the directory name appears to be blank or null (image002). Either way, I would like to know how to just ignore that strange folder altogether if that's possible.

Log zipped and attached.

Thank you for the assistance.
winscp.zip (1.7 MB) [Download]

Description: (none)

image002.png (58.71 KB) [Download]

Description: (none)

image001.png (81.55 KB) [Download]

Description: (none)

martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24995
Location: Prague, Czechia
The file has no name, what confuses the WinSCP parser.

You will have troubles excluding it by its full name due to the perceived presence of slashes in the name.

But you can try to use exclude mask like | *modify=20131010193915*
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License