|This is a page from the Flash Renamer user manual.|
Scripting is form of programming that allows you to extend Flash Renamer and give it new functions! It is not particular hard, but it requires some basic knowledge of computer programming.
Scripts are simple textfiles with the file extension frs (Flash Renamer Script). All scripts must be put in the Script folder inside the settings folder. To begin making your own script, I recommend that you have a look at the example distributed with Flash Renamer, called Example - Base for New Script.frs.
|If you create a useful script, send it to me and I might include it in the next version of Flash Renamer!|
Flash Renamer use the Windows Script Host, which means that it can use any scripting language you have installed on your system. The default is VBScript. To use another language you must enter its name on the first line inside the script (see the example scripts).
When executing, Flash Renamer will call the following functions inside your script.
(Optional) The Init function runs first of all, before anything else. If you return anything from this function it will be printed to the log window.
Flash Renamer will call this function for each file to rename. Return the desired new filename! Return an empty string to skip renaming the file.
(Optional) When all files have been renamed this function is called. If you return anything from this function it will be printed to the log window.
Exposed variables & functions
Flash Renamer exposes parameters and functions though the read-only object
FlashRenamer. The following are available at the moment:
This is the string that Flash Renamer wants you to process. Note that it depends on the "Process Name" and "Process Extension" settings in Flash Renamer.
This always contains the full filename, including extension, in contrast to the above. Use it for reference.
This is simply the path where the file is located.
The arguments you can enter when you run a script in Flash Renamer are delivered through this variable.
This is a function you can call to "render" a format string, just like format strings in Flash Renamer. For example, FlashRenamer.FormatTags("<size>") will return the size of the file!
This is a boolean value (true or false) that tells you if your script is being run to generate the preview or if it is the "real deal".
When running presets, multiple functions process the filename before writing it to disk. Since the filename may have been changed previous to entering your script, you should use .DiskName if you want to access the file on disk.
This always contains to total amount of files that are destined to be renamed
This contains a zero padded id repressenting the order in which the current item is located, relative to the rest of the items being renamed.
This contains the path that is currently loaded in the file browser in Flash Renamer. If using free select mode, this is empty.
Returns a string containing all filenames included in the current rename set. Each filename is separated by an asterix (*).
- The second line of a scripting file may contain a short description of the script that will be displayed in Flash Renamer.
- You can't assume that you get the files in correct order when renaming. A way around this is to use the ItemOrder property (See the included script Create mp3 playlist for an example). Another way is to use the <counter> tag in a smart way.