PowerShell Help: Delete local files after sync

Advertisement

Sundance
Joined:
Posts:
2

PowerShell Help: Delete local files after sync

Dear WinSCP-users,
i'm currently trying to find a way to sync the contents of a local folder to a remote folder and delete the local files after a successful transfer.
I found this power-shell script, but it does it the other way round..

https://winscp.net/eng/docs/library_example_delete_after_successful_download

I'm unfortunately not a PowerShell expert so i'm having difficulties understanding what i need to change.

I changed the SynchonizationMode and the sync works when i execute the script. But the deletion won't work and i don't know what to change.
Any help is greatly appreciated :)

Thanks in advance

Sundance

Reply with quote

Advertisement

Sundance
Joined:
Posts:
2

I figured that using the "put" command with -delete, this gets much easier. The only thing that doesn't seem to work, is syncing ALL files AND folders within the local folder, without deleting the local folder itself.

I'm currently using this command in a bat script:

put -delete -filemask=*/ X:\(LocalPath)\ /(RemotePath)"^
It syncs fine, but deletes the "LocalPath" folder. I can't seem to find a filemask that works. Using
*.*
doesn't sync the first folder within the localpath, but only it's subfolders.

THanks in advance for any help!

Sundance

Reply with quote

jkn
Joined:
Posts:
2
Location:
GER

hi,

similar problem

"get /imp -filemask=*.txt \pfad\imp" ^
"rm /imp *.txt" ^

deletes the whole /imp folder?

...
"rm /imp/ *.txt" ^

works so far with a note in the logfile that the slash isn´t clearly.

Reply with quote

jkn
Joined:
Posts:
2
Location:
GER

hello again

"rm /IN/*.txt" ^

deletes "*.txt" without the note and doesn´t delete the "/IN" directory

works fine - thx

;)

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
31,282
Location:
Prague, Czechia

I'm not sure I understand your problem fully, but maybe you are looking for this:
put -delete -filemask=*/ X:\(LocalPath)\* /(RemotePath)/" ^

Reply with quote

Advertisement

You can post new topics in this forum