Differences
This shows you the differences between the selected revisions of the page.
2011-02-21 | 2011-07-31 | ||
typo (martin) | scriptcommand_* + typo (martin) | ||
Line 1: | Line 1: | ||
- | ====== How do I create script that synchronizes files and deletes synchronized files from source afterwards? ====== | + | ====== How do I create script that synchronizes files and deletes synchronized files from source afterward? ====== |
You have a source local (or remote) folder, where new files are being added by some external process. You want to make sure that these files gets regularly transferred to remote (or local) folder. And you want to remove the source local (or remote) files once they are safely transferred. | You have a source local (or remote) folder, where new files are being added by some external process. You want to make sure that these files gets regularly transferred to remote (or local) folder. And you want to remove the source local (or remote) files once they are safely transferred. | ||
Line 7: | Line 7: | ||
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 never end with the same file being both in source and destination folder, you can simply move the files to the destination folder. | ||
- | You can do this using ''-delete'' switch of the ''[[script_commands#put|put]]'' (or ''[[script_commands#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. |
===== 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 afterwards. | + | 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. |
- | Perform the synchronization using ''[[script_commands#synchronize|synchronize]]'' command. Make sure the script generates [[logging_xml|XML log file]]. You can then [[logging_xml#parse|parse]] the log file to enumerate files that got successfully transferred, and use the list, to generate script to delete the source copies. | + | Perform the synchronization using ''[[scriptcommand_synchronize|synchronize]]'' command. Make sure the script generates [[logging_xml|XML log file]]. You can then [[logging_xml#parse|parse]] the log file to enumerate files that got successfully transferred, and use the list, to generate script to delete the source copies. |
~~NOTOC~~ | ~~NOTOC~~ | ||