After run script folder is deleted

Advertisement

Odeargre
Joined:
Posts:
1
Location:
Portugal

After run script folder is deleted

Hi,

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
close
# Exit WinSCP
exit

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,441
Location:
Prague, Czechia

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\
See https://winscp.net/eng/docs/scriptcommand_get#remarks

Reply with quote

Jan1111
Joined:
Posts:
11
Location:
Germany

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!

Reply with quote

martin
Site Admin
martin avatar

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.

Reply with quote

Advertisement

You can post new topics in this forum