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: Deleting all empty folders using WinSCP

There's no way to delete empty folders with WinSCP scripting.

But once you are using C# anyway, you should switch to WinSCP .NET assembly:
https://winscp.net/eng/docs/library
https://winscp.net/eng/docs/library_ssis

With the assembly, it's way easier to iterate the folders, checking which are empty and deleting them.
Pretty

Deleting all empty folders using WinSCP

Hello,

I'm using WinSCP through an SSIS task.

I'm want to delete all the empty directories in the sftp server, but it doesn't work.

My code :

winscp.StandardInput.WriteLine("open Sftp://" + UserFilesServer + "@" + FilesServer + ":" + WinSCPPort + " -privatekey=" + KeyFilesServer + " -passphrase=" + WinSCPPass);

winscp.StandardInput.WriteLine(" cd " + PathFilesServer);
[...]
winscp.StandardInput.WriteLine(" cd ../" + PathFilesServerEnvoi);
winscp.StandardInput.WriteLine("rmdir *");


Everything works, except the last line "rmdir *" that doesn't have any effect.

I tried to use "rm *<1M" to delete everything that is less than 1MB but it deleted everything in the directory, even if it weights more than 1MB.

Can someone help me with this problem ?

Thank you in advance, best regards.

Pretty.