|
|
File templatesPlease note, that this method is superseded by Ac Script. You can create file templates, for example .bat (batch files), or .vbs (Visual Basic template), where certain tokens (like e.g. $P), will be replaced with adequate information (like currently selected file in Ac Browser Plus), and then you can execute them from ACB. You can create any files (txt,html) but the primary goal was creating .bat or .vbs files so making scripts in the context of currently selected files/folders was possible. As already mentioned this is easier to accomplish with Ac Script. Using existing templatesThey are located at the "scripts" menu. You can also press Ctrl+S to bring the templates dialog window. When clicking a template to run, press Shift, if you want the command window to stay open. Creating new templatesPlease look at the templates located in "%ac browser plus installation folder%\scripts" to learn how to write them. To quickly start with templates, please open some testing folder, where you have some unimportant files, select one or more files, then click the scripts | file templates... menu command (or press Ctrl+S). Choose one of the template, for example: "\renaming\Capitalize first character.vbs" and click "Run". All the selected objects will be renamed. Generally, you may use whichever scripting language you want, be it .bat, .cmd, .vbs, .js languages. The only thing ACB does is replacing special tokens with the information about currently selected files\folders. Let's look at this template:
This is a vbs template. If it will be opened from the "scripts" command menu, then the $P will be replaced with currently selected file. If more than one file is selected, then this code will be duplicated as many times as many files/folders are selected. Adding new templates: just add a new file to the scripts folder. Once again - the best way to learn how ACB handles template files is looking at those templates (usually "C:\Program files\Ac Browser Plus\scripts\")
Templates - syntaxWhichever file you'll choose, ACB will simply replace some tokens and then execute the template (open the file). Look at these two example templates, one .bat and the other one - .vbs file: "show paths.bat" (you can find this template in "%Ac Browser Plus installation folder%\templates\tests and examples" folder): @echo off Absolutely regular .bat file, except for the $P token. It's not very complicated, actually it doesn't do anything interesting, but so it's easier to explain how it works. Well - first ACB will replace this $P token with the path of currently selected file or folder, and then will execute this .bat template, which in turn will display this path. If there is more selected files or folders - this template will be duplicated. Now, let's look at the .vbs file example: "make all lower.vbs" (you can find this template in "%Ac Browser Plus installation folder%\scripts\Renaming" folder): Set fso = CreateObject("Scripting.FileSystemObject") And again, this is a regular .vbs file, except for those "$P", "$U" and other tokens. They will be simply replaced by currently selected files\folders. If there is more than one file\folder selected, ACB will build a big template file, by duplicating the above code. List of tokens:$P: full path (e.g. C:\Windows\notepad.exe) To get short version of name\path, use $p, or $n (lower case). You can run the "show list of tokens.bat" template to display all of those tokens. Click the "Scripts\Test and examples\show list of tokens.bat" menu command. Advanced: FlagsIf you want to e.g. export a list of selected files\folders instead of executing a template, you may do so by using flags in the file. For example, select some files\folders, then click the "Scripts\creating lists\list.htm" menu command. A new file ("list.htm") will be created, with links to all the selected files in current foder. Let's look at this template: list.htm (you can find this template in "%Ac Browser Plus installation folder%\Scripts\creating lists" folder): #acb_flag("RunModes","CreateInCurrentFolder") Those flags at the very beginning of the file mean that ACB is to create the output file in current folder, and, that there should be no space characters added between the lines. OK - just remember, that if you want to create a file in current folder, and this file is supposed to consist of a list of selected files and folders, you should include the two above lines (#acb_flag...). Of course, those lines will not be included in the output file. A list of all flags: #acb_flag("RunModes","CreateInCurrentFolder"): output file will be created in
current folder. And, once again:
Web resources: Download scripting host (from Microsoft) templateing at Microsoft (Visual Basic templateing). http://www.robvanderwoude.com/ - about both, batch (.bat) and .vbs scripting (click WSH in the menu).
|
|
Copyright Konrad Papala; [ACB::Help Online] |