Topic "don't want to delete folder on remote server"

Author Message
[View user's profile]

Joined: 2016-01-21
Posts: 1
I've been exploring the scripting capabilities of winscp today and have stumbled upon something that I can't solve.

Expected behavior
1. Download .pdf and .txt files that from remote_path
2. Delete downloaded files in remote_path after successful download.

Batch Script

@echo off
set session=
set remote_path=/from_me/tmp
set local_path=E:\Shares\FTP\winscp-test
del %path%\test.log

echo open %session% > script.tmp
echo get -filemask="*.txt;*.pdf" %remote_path% %local_path% -resumesupport=on -delete -transfer=automatic >> script.tmp
echo exit >> script.tmp

e:\Shares\FTP\tmp\PortableApps\WinSCPPortable\App\winscp\ /script=script.tmp /loglevel=1 > %local_path%\test.log
del script.tmp

The directory /tmp on remote_path gets deleted. I don't want that. I only want to delete the files that were successfully downloaded, not the directory in which they were stored on remote_path. I have tried to use masks of different kinds but can't get it to work. The directory /tmp is always deleted.

Any help is appreciated! Smile

Problem solved by slightly changing the below line of code.

Added trailing slash and wildcard to remote path and backslash to local path.

echo get %remote_path%/* %local_path%\ -filemask="*.txt;*.pdf|*/" -resumesupport=on -delete -transfer=automatic >> script.tmp

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!


About donations

$9   $19   $49   $99

About donations


WinSCP Privacy Policy

WinSCP License