Write your own script
This functionality can be useful for python programmers, for whom predefined operations are not sufficient,
and they need to specify their own.
When writting script you have to follow same syntactit rules applied to Python syntax in the version 2.7.
It is neccessary to keep correct indent (4 spaces for nested block, first block without indent).
Script you write, is triggered for each file in the list separately, so it basically define the process of transformating
known data into the new file name.
New file name store into the variable new_name. File ID which is currently being processed is stored in the
variable file_id. File name and all other available data are accessible throught metods of local instances.
Settings can be adjusted with local methods.
Local methods
Script you write is triggered inside the class RenameAction.
You don't need to know full specification of this class, only few methods are usefull when writting script. Besides first two functions
all others are setter-functions that enable you to adjust local settings. Values you set will override values set inside GUI.
- numOfFiles()
Return number of files in the file list to rename.
- cancel()
Function interrupts renaming process.
- setDeliminators([str delim1],[str delim2] .. )
Function sets characters that will be catagorised as deliminators. Typical deliminators are space, comma, full-stop.. Deliminators affect process of determining letters case.
-
setLetterSize(str letterSize)
Function sets model of letters case.
Set of allowed values of input parameter letterSize is following:
- 'll' = lower case
- 'LL' = upper case
- 'Ll' = capitalise
- 'lL' = toggled case
- 'Lll' = first letter up
- setChangeOrigLetterSize(bool change)
Function sets whether to change original letters case.
- setNumAccuracy(int whole = -1, int after = -1)
Set minimal number of digits for integer and real numbers (parameter whole), and also num. of decimal digits for real numbers (parameter after). Value -1 means automatic accuracy.
- setEmptyString(str emptyString)
Set empty string, which is used when required data are not available.
-
setDateFormat(str dayName = None, str monthName = None, str year = None)
Set format of displaying the date. Allowed values are follows:
- dayName='long' - display full day name
- dayName='short' - display abbreviation of day name
- monthName='long' - display full month name
- monthName='short' - display abbreviation of month name
- year = 'xxxx' - display all four digits of year
- year = 'xx' - display last two digits of year
- setSizeUnit(str sizeUnit)
Set file size unit. Allowed values are follows: 'B', 'KB', 'MB', 'GB'. Implicitly 'KB' is set.
Note.: You don't have to write keyword self in the front of each method, because these identificators are already localy defined as references to class methods.
Local instances
Within the interface of the class RenameAction (inside of which script is triggered), there is a couple of class instances, interface of which
enable you to access data of particular category denoting particular file which is currently being processed.
Those instances are follows:
Note: You don't have to write keyword self in the front of each of these instances, because these identificators are already localy defined as references to these instances created inside initialization section of RenameAction.
File
Class instace which enables access to the basic properties of the particular file.
All functions have one optional input argument _file (string type),
representing whole file name (including path). If it is not set, than the name of the file which is currently being processed will be used.
- File.whole_name( _file = None)
Return file name. If _file!=None returns directly _file, otherwise name of the file which is currently being processed.
- File.name(_file = None)
Return file name without extension.
- File.baseName( _file = None)
Return file name with extension(if there is any).
- File.ext( _file = None)
Return file extension.
- File.path( _file = None)
Return file path.
- File.size(_file = None)
Return file size.
- File.creation_date, File.access_date, File.modif_date
Instances of the class _file_date, that enable access to the information about date of creation, date of last access and date of last modification of the file.
- File.creation_time, File.access_time, File.modif_time
Instances of the class _file_time, that enable access to the information about time of creation, time of last access and time of last modification of the file.
- File.__call__(_file = None)
Return true on condition that file with name == _file exists, otherwise false.
Current_time
Class instance which enables access to entries of current time.
- Current_time.second()
Return num. of seconds of current time.
- Current_time.minute()
Return num. of minutes of current time.
- Current_time.hour()
Return num. of hours of current time.
- Current_time.__call__()
Return hour()+':'+minute()+' '+second()
Current_date
Class instance which enables access to entries of current date.
- Current_date.dayName()
Return current day name.
- Current_date.day()
Return current day number.
- Current_date.monthName()
Return current month name.
- Current_date.month()
Return current month number.
- Current_date.year()
Return current year.
- Current_date.__call__()
Return day()+'.'+month()+'.'+year()
Image
Class instance which enables access to basic image properties.
All functions have one optional input argument _file (string type),
representing whole file name (including path). If it is not set, than the name of the file which is currently being processed will be used.
- Image.width(_file = None)
Return image width in pixels.
- Image.height(_file = None)
Return image height in pixels.
- Image.mode(_file = None)
Return image modeu (RGB / BW / CMYK ..).
- Image.library()
Return True in case library for accessing image properties is available, False otherwise.
- Image.__call__(_file = None)
Return True if file with name == _file exists and it is image, False otherwise.
Exif
Class instance which enables access to basic entries in EXIF structure of image file.
All functions have one optional input argument _file (string type),
representing whole file name (including path). If it is not set, than the name of the file which is currently being processed will be used.
- Exif.camera_maker(_file = None)
Return string with name of camera manufacturer.
- Exif.camera_model(_file = None)
Return string with name of camera model.
- Exif.F_stop(_file = None)
Return F-number (float).
- Exif.ISO(_file = None)
Return ISO (float).
- Exif.focal_length(_file = None)
Return focal length (float).
- Exif.library()
Return True in case library for accessing image properties is available, False otherwise.
- Exif.__call__()
Return True if file with name == _file exists and contains Exif metadata, False otherwise.
ID3
Class instance which enables access to entries in ID3 structure of sound file.
All functions have one optional input argument _file (string type),
representing whole file name (including path). If it is not set, than the name of the file which is currently being processed will be used.
- ID3.artist(_file = None)
Return string with artist name.
- ID3.album(_file = None)
Return string with album name.
- ID3.track_name(_file = None)
Return string with track name.
- ID3.track_num(_file = None)
Return track number in album.
- ID3.music_style(_file = None)
Return string with name of music style.
- ID3.year_of_release(_file = None)
Return year of album release.
- ID3.comment(_file = None)
Return string with comment embedded into ID3.
- ID3.setNew(self,_file = None, artist=None, album=None, track_name=None, track_num=None, music_style=None, year=None, comment=None)
Function enables to write new values into ID3 structure. Returns True/False in case of success/non-success.
- ID3.library(_file = None)
Return True in case library for accessing ID3 metadata is available, False otherwise.
- ID3.__call__(_file = None)
Return True if file with name == _file exists and it is sound file with ID3 metadata.
MusicBrainz
Class instance which enable gather data from internet music metadatabase MusicBrainz.org.
Data are searched on the basis of explicitly entered information(Explicit_data), ID3 inf. and from results of automatic parsing (Auto_parser).
All functions have one optional input argument _file (string type),
representing whole file name (including path). If it is not set, than the name of the file which is currently being processed will be used.
For correct functionality it evidently requires access to the internet.
It is also important to take into consideration, that method execution for gathering particular data will take significant amount of time.
Therefore each of methods contain one optional argument timeout, which define maximum time(in seconds) that methods can consume by one execution. If not entered, methods will not be time-restricted.
Next optional arguments are urls and only_urls. Urls is a list of predefined adress of albums from MusicBrain.com, from which data are supposed to be gathered primarily.
Only_url specify whether only these adress will be used, or the program is allowed to search for some additional ones.
- MusicBrainz.artist(_file = None,urls = [], only_urls = False,timeout=None)
Return string with artist name.
- MusicBrainz.album(_file = None,urls = [], only_urls = False,timeout=None)
Return string with album name.
- MusicBrainz.track_name(self,_file = None,urls = [], only_urls = False,timeout=None)
Return string with track name.
- MusicBrainz.track_num(self,_file = None,urls = [], only_urls = False,timeout=None)
Return track number in album.
- MusicBrainz.year_of_release(self,_file = None,urls = [], only_urls = False, timeout=None)
Return year of release.
- MusicBrainz.library()
Return True in case musicBrainz.py library is available, otherwise False.
Explicit_data
Class instance for managing explicitly entered data.
Under the term explicit data it is meant data entered by user(not programmer), which he knows, but these data are not embedded into the file name
neither into file metadata structures. Therefore use setter-functions inside script is not recommended, neither meaningful.
All functions have one optional input argument _file (string type),
representing whole file name (including path). If it is not set, than the name of the file which is currently being processed will be used.
- Explicit_data.new_file_name(_file = None)
Return string with new file name entered by user.
- Explicit_data.set_new_file_name(data, _file = None)
Set new file name.
- Explicit_data.artist(_file = None)
Return string with artist name entered by user.
- Explicit_data.set_artist(data, _file = None)
Set artist name.
- Explicit_data.album(_file = None)
Return string with album name entered by user.
- Explicit_data.set_album(_file = None)
Set album name.
- Explicit_data.track_name(_file = None)
Return string with track name entered by user.
- Explicit_data.set_track_name(data,_file = None)
Set track name.
- Explicit_data.track_num(_file = None)
Return string with track number entered by user.
- Explicit_data.set_track_num(_file = None)
Set track number.
- Explicit_data.episode_num(_file = None)
Return episode number(in the particular session) entered by user.
- Explicit_data.set_episode_num(_file = None)
Set episode number.
- Explicit_data.season_num(_file = None)
Return season number entered by user.
- Explicit_data.set_season_num(_file = None)
Set season number.
- Explicit_data.serial_name(_file = None)
Return string with serial name entered by user.
- Explicit_data.set_serial_name(_file = None)
Set serial name.
- Explicit_data.episode_name(_file = None)
Return string with episode name entered by user.
- Explicit_data.set_episode_name(_file = None)
Set episode name.
- Explicit_data.release_type(_file = None)
Return type of release (e.g. Tvrip, bdrip, dvdrip, cam..).
- Explicit_data.set_release_type(_file = None)
Set type of release.
- Explicit_data.year_of_release(_file = None)
Return year of release of track/film/episode/serial entered by user.
- Explicit_data.set_year_of_release(_file = None)
Set year of release.
- Explicit_data.uploader(_file = None)
Return uploader's pseudonym.
- Explicit_data.set_uploader(_file = None)
Set uploader's pseudonym.
Auto_parser
Class instance that enables access to the data gathered by automatic parsing of original file name.
It is experimental feature, thus results are not completely accurate. This functionality is applied on sound, video and subtitle files.
All functions have one optional input argument _file (string type),
representing whole file name (including path). If it is not set, than the name of the file which is currently being processed will be used.
- Auto_parser.artist(_file = None)
Return string with artist name.
- Auto_parser.album(_file = None)
Return string with album name.
- Auto_parser.track_name(_file = None)
Return string with track name.
- Auto_parser.track_num(_file = None)
Return track number.
- Auto_parser.episode_num(_file = None)
Return episode number(in the particular season).
- Auto_parser.season_num(_file = None)
Return season number.
- Auto_parser.episode_name(_file = None)
Return episode name.
- Auto_parser.serial_name(_file = None)
Return serial name.
- Auto_parser.release_type(_file = None)
Return type of release (e.g. Tvrip, bdrip, dvdrip, cam..).
- Auto_parser.year_of_release(_file = None)
Return year of release of track/movie/episode/serial entered by user.
- Auto_parser.uploader(_file = None)
Return uploader's pseudonym.