Differences
This shows you the differences between the selected revisions of the page.
2018-11-30 | 2019-03-22 | ||
moving anchor (martin) | better wording + examples + separating scripting and .net part (martin) | ||
Line 5: | Line 5: | ||
===== [[moving]] Moving Files ===== | ===== [[moving]] Moving Files ===== | ||
- | Supposing you never end with the same file being both in source and destination folder, you can simply move the files to the destination folder. | + | Supposing you always want to upload all files from the source to the destination folder, you can simply move the files to the destination folder. |
You can do this using ''-delete'' switch of the ''[[scriptcommand_put|put]]'' (or ''[[scriptcommand_get|get]]'') command. WinSCP deletes the source file, when it is successfully transferred to the destination folder only. | You can do this using ''-delete'' switch of the ''[[scriptcommand_put|put]]'' (or ''[[scriptcommand_get|get]]'') command. WinSCP deletes the source file, when it is successfully transferred to the destination folder only. | ||
+ | |||
+ | <code winscp> | ||
+ | put -delete C:\source\* /dest/ | ||
+ | </code> | ||
===== Synchronizing and Deleting Transferred Files ===== | ===== Synchronizing and Deleting Transferred Files ===== | ||
- | If it can happen that the same file is both in source and destination folder, you can use synchronization and delete only transferred files afterward. | + | If it can happen that the same file is both in the source and the destination folder, and you do not want to upload such files, you can use synchronization and delete only transferred files afterward. |
A simple way to implement this is using both ''-delete'' and ''-neweronly'' switches of the ''[[scriptcommand_put|put]]'' (or ''[[scriptcommand_get|get]]'') command | A simple way to implement this is using both ''-delete'' and ''-neweronly'' switches of the ''[[scriptcommand_put|put]]'' (or ''[[scriptcommand_get|get]]'') command | ||
+ | |||
+ | <code winscp> | ||
+ | put -delete -neweronly C:\source\* /dest/ | ||
+ | </code> | ||
+ | |||
+ | ---- | ||
If you need more control (like if you want to delete the files only after all of them are transferred successfully), you can implement this easily using [[library|WinSCP .NET assembly]]. See example [[library_example_delete_after_successful_download|Deleting remote files after successful remote to local synchronization]]. | If you need more control (like if you want to delete the files only after all of them are transferred successfully), you can implement this easily using [[library|WinSCP .NET assembly]]. See example [[library_example_delete_after_successful_download|Deleting remote files after successful remote to local synchronization]]. |