Difference between revisions of "ReNamer:Pascal Script"
m (Add link at tips to page "ReNamer:Scripts:Reuse variable") |
(move reuse variables article to cookbook) |
||
Line 42: | Line 42: | ||
# [[ReNamer:Pascal Script:Import functions|How to import functions]] | # [[ReNamer:Pascal Script:Import functions|How to import functions]] | ||
# [[ReNamer:Pascal Script:SplitPath|How to split file path into parts (folders, base, extension)]] | # [[ReNamer:Pascal Script:SplitPath|How to split file path into parts (folders, base, extension)]] | ||
+ | # [[ReNamer:Scripts:Reuse variable|How to store/load variables for later reuse]] | ||
== Scripts repository == | == Scripts repository == | ||
Line 64: | Line 65: | ||
'''Important:''' The only product of PascalScript that doesn't affect your files until Rename operation is the content of the FileName variable. "New Name" (and "New Path") fields of filetable are replaced with this variable content. After Preview you may check if you like them and if you do - press Rename. Only then the actual renaming of the files will take place. | '''Important:''' The only product of PascalScript that doesn't affect your files until Rename operation is the content of the FileName variable. "New Name" (and "New Path") fields of filetable are replaced with this variable content. After Preview you may check if you like them and if you do - press Rename. Only then the actual renaming of the files will take place. | ||
− | |||
− | |||
− | |||
− | |||
== External links == | == External links == |
Revision as of 15:47, 27 January 2013
The PascalScript Rule in ReNamer uses Pascal Script component to allow users to program their own renaming rule.
To master Pascal Script, follow these steps:
- Learn the basic syntax and concepts of Pascal Script
- Understand the specific variables, procedures and functions that are defined within ReNamer
- Learn how to use these variables/functions/procedures in scripts
Let us see these steps in more details.
Learn the basics
To learn the basics of Pascal Script, please refer to the Pascal Script Quick Guide.
Types and functions
In this section, we will see all types, procedures and functions which can be used within ReNamer.
Note: Most of these are not part of the "standard" Pascal Script, so you will not find them in other applications.
Script cookbook
In this section, we will see how to write scripts for some common renaming tasks.
They also demonstrate how to use ReNamer's types, procedures and functions.
- How to rename a file (using the FileName variable)
- How to skip extention (basic FileName utilities)
- How to convert the filename to ALLCAPS (the WideUpperCase function)
- How to operate on words (Unicode string-handling routines)
- How to serialize files (basic conversion routines)
- How to initialize variables
- How to create interactive dialogs
- How to work with folders and paths (FilePath constant)
- How to break the script execution
- How to read file content
- How to import functions
- How to split file path into parts (folders, base, extension)
- How to store/load variables for later reuse
Scripts repository
- Official Scripts Repository.
- The Forum contains several ready scripts.
Study them and adopt them for your purpose.
Tips
A few quick tips:
- In Pascal Script, ReNamer has defined the FileName variable to represent the New Name of the File.
Therefore, in your script, you will have to manipulate this variable to change the filename. - The FilePath constant holds the original path of the file. It allows you to access the file directly.
- ReNamer supports UDFs (User-Defined Functions) and also importing of external functions from DLLs.
- Try to use WideString type instead of an ordinary String type. This will allow ReNamer to handle Unicode filenames.
(In other words, it will be able to handle non-English scripts, such as Cyrillic, Asian, German, French, etc.)
Warning: Do not override ReNamer's built-in variables, types and functions.
Warning: Some of the functions are able to alter your file system (create new folders, move files, etc.). So use them with caution! Remember that scripts are executed during Preview (NOT Rename) operation. So you let the script alter your system by pressing Preview or having Auto Preview on.
Important: The only product of PascalScript that doesn't affect your files until Rename operation is the content of the FileName variable. "New Name" (and "New Path") fields of filetable are replaced with this variable content. After Preview you may check if you like them and if you do - press Rename. Only then the actual renaming of the files will take place.
External links
- Developers of the Pascal Script component.
- Help and reference for the fundamentals of the Delphi/Pascal language.