updata:简体版官方帮助有翻译,但是有些翻译还是沿袭了老版本的习惯而没有更新。
脚本概览
Beyond Compare提供了一个脚本处理的特性,命令行方式启动才有效,它允许你用文件夹查看器模式自动运行常规任务。 脚本是一个简单的文本文件,包含一系列命令,它可以控制程序自动执行文件操作。
脚本运行的时候不显示常规文件夹查看器窗口,但可能需要确认某些输入。若想执行一个脚本,在命令行参数中指定名称并在其前加上”@”符号,类似这样:
BC2.exe @C:\BC2\MyScript.txt
简单的说,脚本是由一系列简单的命令组成的,最短的有意义的脚本就像这样:
load "C:\Windows\Temp"
select all
delete all
它会删除Windows的Temp目录下的所有文件和文件夹。
脚本在本质上是一个无形的文件夹比较器:文件操作需要选择,显示受筛选器的限制,文件夹可以逐层展开。文件夹名参数可以是系统和网络中的文件夹,或者ftp站点,以及类似文件夹的档案,例如.ZIP, .CAB, 或者 Beyond Compare 快照文件。
脚本是逐行处理的,每行一条命令。脚本不区分大小写,空行和注释行(#号打头)会被忽略。参数用空格分开,若参数中包含空格,用引号隔开(”)。如果命令太长想用两行或者三行显示,在每行的末尾加入”&”符号,除了最后一行。
In addition to the standard commands, command line parameters and environmental variables can be inserted into the script at run time. Command line variables are specified by a percent sign (%) and a single number from 1-9. The script name and command line switches starting with / are not included in the 1-9 list. The scripting command:
load "%1"
would load whatever session was given on the command line, as in “BC2 @script.txt MySession”.
Environmental variables are inserted by enclosing the variable name in percent signs, and are case sensitive. The following performs the same as the earlier script, except it gets the folder from the environment:
load "%TMP%"
select all
delete all
There are several dynamic variables that Beyond Compare can fill in at each line of the script. The %date% variable fills in the current date in the format yyyy-mm-dd. The %time% variable’s format depends on your computer’s regional settings. The %fn_time% variable outputs the time as hh-mm-ss, which can be used for filenames.
Scripting Options
The only meaningful switch to script processing is the /silent switch. Normally, script processing adds an entry on the Task Bar and displays a Scripting Status Window detailing its progress and any errors. This switch bypasses the Task Bar entry and Scripting Status Window, allowing Beyond Compare to process the script invisibly.
To change the script processing options, select Options from the Tools Menu. Check the Beep when finished option to have Beyond Compare sound an audible beep when it completes script processing. This beep can alert you to check and close the Scripting Status Window. Close when finished has Beyond Compare automatically close its Scripting Status Window when it completes script processing. When used in conjunction with Beep when finished, the beep simply tells you the process has completed.
There is also a place to designate a Shared Scripts Folder. When you provide a script name argument on the command line with no path designation, and there is no file of that name in the current folder, Beyond Compare will look in the Shared Scripts Folder for that script.
See also
Scripting reference
Sample scripts
Recent Comments