Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

martin

Re: Session.Getfiles when removal set to $true

Alcasczar wrote:

If I set the variable to

$remotePath = '/test/script/files/*'

When calling getfiles($remotePath,$localPath,$true,$tranferOptions) there's an error , I guess it doesn't like the "*" at the end when it's part of the variable? Should it be escaped perhaps?

That should not be a problem. Show us a session log file.
Alcasczar

Is there a method or function that can be used to Continue instead of abort? say for example I'm downloading in batch and use (Powershell)

$TransferResult.Check()

I'd like to keep going for every file and just log those that don't.
Alcasczar

Re: Session.Getfiles when removal set to $true

martin wrote:

Probably because the $remotePath is /test/script/file and not correct /test/script/file/*


Thank you Martin.

Actually it was set like this

$remotePath = '/test/script/files/'

If I set the variable to

$remotePath = '/test/script/files/*'

When calling getfiles($remotePath,$localPath,$true,$tranferOptions) there's an error , I guess it doesn't like the "*" at the end when it's part of the variable? Should it be escaped perhaps?
martin

Re: Session.Getfiles when removal set to $true

Probably because the $remotePath is /test/script/file and not correct /test/script/file/*
Alcasczar

Session.Getfiles when removal set to $true

Using Powershell 3.0
Using .NET Assembly 5.9

Any ideas why after the script process $Session.getfiles($remotepath, $localpath, $true, $transferOptions)

it's trying to delete the directory? I had thought it would only do this for "files" not directories. Is there anyway to only delete files after transfer and leave directory structure on the remote side? I looked at Session.SyncronizeDirectory method but that appears to put me in the same boat, maybe

Here's just a clip of the code. It works fine on another sftp server as I expect (doesn't try to delete the directory)

 $transferOptions = New-Object WinSCP.TransferOptions

        $transferOptions.TransferMode = [WinSCP.TransferMode]::Binary
        $transferOptions.ResumeSupport.State = [WinSCP.TransferResumeSupportState]::Off
        $transferOptions.FileMask = "*.*|.no_delete,*.part,*.tmp"
             
         
        $transferResult = $session.GetFiles($remotePath, $localPath, $True, $transferOptions)
             
     
        $transferResult.Check()


VERBOSE: Error: Error deleting file '/test/script/file'.
Permission denied.
Error code: 3
Error message from server (en-US): Permission denied


I also looked at batch mode emulation, but not sure how to change the default from abort mode to continue, this may help me workaround it for now.

Thanks for the assistance