4

I'm trying to download files from a big tree of recursive directories, and I want the downloaded files to be removed after download. When I put true in remove parameter of GetFiles, it removes all the directories, but I want it to remove only the files and leave the directories empty. Is there any way to do it? Thank you.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
user5441417
  • 101
  • 3
  • 9

1 Answers1

3

Use WinSCP extension Recursively move files in directory tree to/from SFTP/FTP server while preserving source directory structure.


Some alternatives:


A more complicated, but more efficient (if you have a large amount of files) approach would be:

  • Replicate the directory structure in a remote temporary folder.
  • Move all the files there, directory by directory, using Session.MoveFile. Despite the name, the method accepts wildcards.
  • Download and delete the temporary tree at once using Session.GetFiles with remove set to true.
Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992