Post a reply

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)


Topic review


Re: After run script folder is deleted

Not with simple WinSCP scripting. You would have to use more powerful language, like PowerShell with use of WinSCP .NET assembly. After all, you already have such script.

Alternatively, keep your original solution and move the downloaded file one level up after the transfer.

Re: After run script folder is deleted

Is there a solution for dynamic Folder-Names? In the example the Subfolder Cartas_Garantia is a static folder with static name. In my case the folders were creates automatically and all I know is, that they beginn with 20*.

Thanks alot!

Re: After run script folder is deleted

Instead of selecting the folder for the transfer, you need to select the files in the folder:
get -delete /wortends/CartasdeGarantia/Cartas_Garantia/* -filemask=Carta*.pdf  D:\FTP\IN\Teste\

Or, if the download is not recursive a simpler syntax:
get -delete /wortends/CartasdeGarantia/Cartas_Garantia/Carta*.pdf D:\FTP\IN\Teste\


After run script folder is deleted


After running the script the folder Cartas_Garantia is always deleted with the files, i only need to delete the files.

The remote directory is /wortends/CartasdeGarantia/Cartas_Garantia/ after running the script the remote directory stays like this /wortends/CartasdeGarantia/.
# Automatically abort script on errors
option batch abort
# Disable overwrite confirmations that conflict with the previous
option confirm off
# Connect to remote machine
open sftp:(...)
# Change remote directory
cd /wortends/CartasdeGarantia/Cartas_Garantia/
# Download file to the local directory D:\FTP\IN\Teste
get -delete /wortends/CartasdeGarantia/Cartas_Garantia -filemask=Carta*.pdf  D:\FTP\IN\Teste\
# Disconnect
# Exit WinSCP