The script method is probably the most advanced feature of Advanced Renamer. With this method a JavaScript experienced user can extend Advanced Renamer by writing custom methods right in the program. As with any method, the script method can be saved and opened by any other user on any other computer. Write the script in the text box and click Apply Script to see the result in the file list. The Pre Batch Script button can be used to setup prebatch variables.
Important resources:
JavaScript Reference
JavaScript Guide
Note, Advanced Renamer uses an embedded light weight JS engine, so don't expect all the features of a full blown JS engine.
How to use
The script in the method panel will get executed once for every file or folder in the list in the order the files are sorted in the list. The parameter "index" contains the number the item in the list has. The parameter "item" is an object representing an item in the list and contains every piece of information Advanced Renamer knows about this file or folder. The information can be used to create a new filename which will be set by returning the new filename. Remember the new filename must contain the extension of the file.
Objects specific to Advanced Renamer:
The app object has the following properties and methods:
app.currentIndex [readonly] | The index of the currently processed item in the list. |
app.currentItem [readonly] | The currently processed item in the list. |
app.exifToolValue(tag): string | Returns the value of the specified tag from the ExifTool. |
app.getItem(index) | Returns the item at the specified index. |
app.itemCount [readonly] | The number of items in the list. |
app.log(message) | Writes a message to the log. To see the log messages, open the JS console through the button in the main toolbar. |
app.logItem(item) | Writes a message to the log containing the item. |
app.parseTags(tags): string | Parses the specified string for tags and returns the result. |
app.prevItem [readonly] | The previous item in the list. |