Topic "Get files in subfolders and delete after copy, but leave folder structure?"

Author Message
Switchkat

Guest


Hi all. I've been scouring the forums for days but have not been able to find the answer I'm looking for. I have a working script that traverses all the sub-folders in a root folder, gets the files, and then deletes all files that were transferred, but it also deletes the folder structure on the SFTP site.

Is it possible to leave the folder structure and only delete the files that were transferred?

Here's the script I'm using now.
Code:

     "option batch continue" ^
   "option confirm off" ^
   "get -transfer=binary -delete -filemask=*.docx * .\" ^
   "close" ^
   "exit"


Thanks
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24530
Location: Prague, Czechia
It would be very difficult with scripting only.

Though it's doable with WinSCP .NET assembly.

Start with this example:
http://winscp.net/eng/docs/library_example_recursive_download_custom_error_handling

Just replace the Session.GetFiles call with Session.RemoveFiles call and remove the code for creating local directory structure.
Behemoth

Guest


Can you leave a holding file in each remote folder (eg an empty text file or similar) and exclude it from the get via filemask? If the remote folders aren't empty they shouldn't be deleted I believe.

I'm no expert, just an idea I had while looking to solve the same problem.
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