Differences
This shows you the differences between the selected revisions of the page.
2009-02-20 | 2009-04-10 | ||
typo (martin) | synchronize_any (martin) | ||
Line 141: | Line 141: | ||
</code> | </code> | ||
+ | ===== [[synchronize_any]] Shortcut to synchronize any local file with remote directory ===== | ||
+ | You may want to have script that synchronizes any local directory with a same-named subdirectory of fixed remote path, e.g.: | ||
+ | * ''c:\www\gallery'' with ''/home/user/www/gallery''; | ||
+ | * ''c:\documents and settings\martin\www\forum'' with ''/home/user/www/forum'. | ||
+ | Such script is particularly useful for integrating with Windows Explorer's 'Send To' menu. | ||
+ | First create wrapper batch file to store the paths you want to synchronize into environment variables (change ''/home/user/www/'' to remote path root you want to synchronize against): | ||
+ | <code> | ||
+ | set LOCAL=%1 | ||
+ | set REMOTE="/home/user/www/%~n1%~x1" | ||
+ | winscp.com /script=example.txt | ||
+ | </code> | ||
+ | |||
+ | The script ''example.txt'' may look like: | ||
+ | |||
+ | <code winscp> | ||
+ | # Being intended for interactive session, we are not enabling batch mode | ||
+ | # Connect | ||
+ | open session | ||
+ | # Synchronize paths provided via environment variables | ||
+ | synchronize remote %LOCAL% %REMOTE% | ||
+ | </code> | ||
+ | |||
+ | Then you can make a shortcut to the batch file: | ||
+ | * When placed on desktop, you can drop any local directory to it to start synchronization; | ||
+ | * When placed to ''C:\Documents and Settings\username\SendTo'', you can use //Send To > Your Shortcut'' from context menu of any local directory. |