FTP Sync Download and Delete

Advertisement

Xekei
Joined:
Posts:
5
Location:
Czech Republic

FTP Sync Download and Delete

Hello

I want to apologize in advance for my English is not very good.
Getting Started with WinSCP and I need advice...

I want to run a script automatically at an interval of every 60 minutes

- Connect to the FTP server (TLS Explicit)
- Download all the files in a folder
- After downloading a file to an FTP server, delete

Can anyone be so helpful and give an example of a script and how to use it thank you

Reply with quote

Advertisement

sgarciav
Guest

Hi,

I have a nee similar to yours. I looked at the documentation for WinSCP and fund this list of commands:

https://winscp.net/eng/docs/scripting#commands

The command to delete a remote file is rm. Then if you scroll down further you'll see an example that transfers a file from the FTP server to the local machine (then transfers it back). You can use this example, minus the second part. Just use the rm statement after the get command and before the close command.

Also, since you want o transfer many files, use the mget command with *.* instead of "get" and use the rm also with the *.* wildcards.

I wish that this could work for my situation. In my case files are continuously added to the FTP server, so if I use rm *.* I might delete files that came in after the mget process started and were not transferred to the local machine. Good luck, Salvador

Reply with quote

sgarcia
Guest

Re: FTP Sync Download and Delete

Also, I just found this forum entry:

https://winscp.net/forum/viewtopic.php?p=46736#46736

It might be exactly what we are both looking for. Salvador



Xekei wrote:

Hello

I want to apologize in advance for my English is not very good.
Getting Started with WinSCP and I need advice...

I want to run a script automatically at an interval of every 60 minutes

- Connect to the FTP server (TLS Explicit)
- Download all the files in a folder
- After downloading a file to an FTP server, delete

Can anyone be so helpful and give an example of a script and how to use it thank you

Reply with quote

Xekei
Joined:
Posts:
5
Location:
Czech Republic

Thanks for the answer

I had a lot of work and I could not answer before


I am trying to use the command "get -delete *.*" This command deletes but folders and subfolders
I want to folders and subfolders maintained (not deleted)

What command should I use?

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
40,476
Location:
Prague, Czechia

You should better describe your requirements.
Do you want to download (and delete) the files in subfolders?
Or do you want to download (and delete) only files exactly in download directory (but not in its subfolders)?

Reply with quote

Advertisement

Xekei
Joined:
Posts:
5
Location:
Czech Republic

prikryl: Dobrý den,

Budu psát česky protože moje angličtina není dobrá a nedokážu popsat přesně o co se snažím.

Chci spouštět skript automaticky v intervalu jednou za 60 minut
Aby se v kořenovém adresáři i ve složkách a podsložkách na serveru kde se nachází soubory všechny přesunuli do lokálních složek a podsložek které jsou shodné (Shodné myslím umístění a názvy složek)

(Jestli to říkám dobře snažím se o jednosměrnou synchronizaci)

Soubory které chci přesouvat mají vygenerované jméno takže nemohu přesouvat určité soubory podle jména

Příklad:

Když bude na serveru složka která bude mít název xxx a v ní bude soubor 1.txt
A v lokálním adresáři bude taky složka s názvem xxx.

Skript pošle soubor 1.txt do složky xxx v lokálním adresáři.
Soubor se přesune takže na serveru bude tento soubor smazaný (po kompletním přesunutí)

Tohle chci ale pro více složek a souborů

Děkuji za odpověď...

PS: Děkuji za vývoj tohoto programu

Reply with quote

martin
Site Admin
martin avatar

A v cem je problem? Tohle dela get -delete.
Nebo potrebujes aby vzdaleny adresar xxx zustal zachovan? (get -delete ho smaze).

Reply with quote

Xekei
Joined:
Posts:
5
Location:
Czech Republic

Velice děkuji za odpověd ano potřebuji aby byl adresář právě zachován :(

Jde to nějak udělat aby složka byla zachována ?

EDIT:
Jestli tato možnost neexistuje bylo by možné jí přidat do beta verze ?
nějaký příkaz který nemaže složky a podsložky...

Podle mě by bylo nejlepší kdyby ve výchozím nastavení se složky nemazaly příkazem get -delete
a při přídaní nějakého příkazu byly zahrnuty složky kdo by je chtěl také mazat

Reply with quote

Advertisement

martin
Site Admin
martin avatar

Ne automaticky. Samozrejme si muzes naimplementovat rekurzivni prochazeni a mazani souboru sam. Zvlast pres WinSCP .NET assembly to neni slozite.

Reply with quote

HomerSimpsons
Joined:
Posts:
1

Dobrý večer,

Řeším naprosto stejný problém, ale bohužel neumím programovat a nevím ani co znamená "naimplementovat rekurzivni prochazeni" a už vůbec nevím co mám dělat "WinSCP .NET"

byl by někdo tak ochotný a pomohl by mě s tím?

Reply with quote

Advertisement

You can post new topics in this forum