天问

winscp自定义命令

putty登录远程可以执行任意shell命令,而很多常用命令可以使用winscp可视化操作即可,比如删除文件,shell命令:rm xx.txt。而使用winscp可以直接右键菜单删除:

对于一些其他shell命令(tar,zip,mkdir,rm -Rf 等等)也可以自定义。

-----------引

(1)比较目录

&File Compare

cmd /c fc "!" "!^!" | more && pause

(这是本地执行的命令)

 

(2)tar解压缩

Ta&r/GZip...

tar -cz -f "!?&Archive Name:?archive.tgz!" !&

理解这个格式即可:    !?prompt[\]?default!

&UnTar/GZip...

tar -xz --directory="!?&Extract to directory:?.!" -f "!"

 

(3)zip解压缩

Zip(&P)

zip -r "!?Archive Name(&A):?archive.zip!" !&

UnZip(&Z)

unzip -d "!?Extract to directory(&E):?.!" "!"

 

(4)快速删除

默认winscp提供删除右键,但是对于文件夹来说,会一个一个删除里面的文件,如果文件夹里面文件很多,删除的速度非常慢,于是可以调用远程shell命令rm -rf xx 快速删除:

quick rm

rm -rf !&

 

(5)远程同步

 

(6)远程对比

附录:winscp自定义命令参数说明:

Pattern Command Type Description
!! Any Is replaced with exclamation mark (!).
! Any File path (a relative path to a root of an operation, when referring to remote file; an absolute path when referring to a local temporary copy of a remote file). Command with the pattern will be executed once for every selected file. In general it should be surrounded with quotes for the command to work with filenames containing spaces. Cannot be combined with pattern !&.
!& Any Quoted, space-delimited list of paths to files (see ! for path format explanation). Command with the pattern will be executed only once for all selected files. Cannot be combined with pattern ! and executed recursively.
!/ Any Current remote path. The path always ends with slash.
!S Any Current session URL. You can use it to pass current session data to another instance of WinSCP (using command-line or scripting command open), or code using WinSCP .NET assembly (see SessionOptions.ParseUrl). Password is included if stored or remembered only.
!@ Any Current session hostname.
!U Any Current session username.
!P Any Current session password (if stored or remembered).
!# Any Current session port number.
!N Any Current session name.
!?prompt[\]?default! Any When used, user is prompted to enter value that replaces the pattern. prompt can define a message of the prompt and default a default value, both can be empty. Special characters entered by user are automatically delimited. You can prohibit this using optional backslash (\) before second question mark (?).
When implementing an extension, use a runtime option instead, as a more flexible alternative.
!`command` Any Replaced with output of a given local console command.
The command can also be used solely for its side effect, without actually outputting anything.
Limited set of static patterns can be used in command. Particularly file patterns, like ! and !&, cannot be used.
!^! Local Full path to a local file. In general it should be used in a combination with ! or !&. Command with the pattern will be executed once for every selected local file, unless only one local file and several remote files are selected and pattern ! is used. Cannot be executed recursively.
!\ Local Current local path. The path never ends with backslash.

 

博客地址:http://blog.yoqi.me/?p=4347
扫我捐助哦
喜欢 5

这篇文章还没有评论

发表评论