![]() |
Avidemux 2.6 Scripting Reference
|
The Directory class provides access to directory structures and their contents. More...
Public Types | |
enum | Filter { Directories = 0x001, Files = 0x002, Drives = 0x004, NoSymLinks = 0x008, AllEntries = Directories | Files | Drives, Readable = 0x010, Writable = 0x020, Executable = 0x040, Modified = 0x080, Hidden = 0x100, System = 0x200, AllDirectories = 0x400, CaseSensitive = 0x800, NoDotAndDotDot = 0x1000, NoFilter = -1 } |
Describes the filtering options available to Directory; e.g. for entryList() and entryInfoList(). More... | |
enum | Sort { Name = 0x00, Time = 0x01, Size = 0x02, Type = 0x80, Unsorted = 0x03, DirectoriesFirst = 0x04, Reversed = 0x08, IgnoreCase = 0x10, DirectoriesLast = 0x20, LocaleAware = 0x40, NoSort = -1 } |
Describes the sort options available to Directory, e.g. for entryList() and entryInfoList(). More... |
Public Member Functions | |
String | absoluteFilePath (String fileName) |
Returns the absolute path name of a file in the directory. | |
Boolean | changeDirectory (String dirName) |
Changes the Directory object's directory to dirName. | |
Boolean | changeDirectoryUp () |
Changes directory by moving one directory up from the Directory object's current directory. | |
String | cleanPath (String path) |
Removes all multiple directory separators "/" and resolves any "." or ".." found in the path. | |
Directory (String path="") | |
Constructs a Directory object pointing to the given directory path. If path is empty the program's working directory, ("."), is used. | |
Directory (String path, String nameFilter, Sort sort=Sort(Name|IgnoreCase), Filter filter=AllEntries) | |
Constructs a Directory object with specified path, that filters its entries by name using nameFilter and by attributes using filter. It also sorts the names using sort. | |
Array | entryInfoList (Filter filters=NoFilter, Sort sort=NoSort) |
Returns a list of FileInformation objects for all the files and directories in the directory, ordered according to the name and attribute filters previously set with the nameFilters and filter properties, and sorted according to the flags set with the sorting property. | |
Array | entryInfoList (Array nameFilters, Filter filters=NoFilter, Sort sort=NoSort) |
Returns a list of FileInformation objects for all the files and directories in the directory, ordered according to the name and attribute filters previously set with the nameFilters and filter properties, and sorted according to the flags set with the sorting property. | |
Array | entryList (Filter filters=NoFilter, Sort sort=NoSort) |
Returns a list of the names of all the files and directories in the directory. | |
Array | entryList (Array nameFilters, Filter filters=NoFilter, Sort sort=NoSort) |
Returns a list of the names of all the files and directories in the directory. | |
Boolean | exists (String name) |
Returns true if the file called name exists; otherwise returns false. | |
String | filePath (String fileName) |
Returns the path name of a file in the directory. | |
String | fromNativeSeparators (String pathName) |
Returns pathName using '/' as file separator. | |
Boolean | makeAbsolute () |
Converts the directory path to an absolute path. | |
Boolean | makeDirectory (String dirName) |
Creates a sub-directory called dirName. | |
Boolean | makePath (String dirPath) |
Creates the directory path dirPath. | |
Boolean | match (Array filters, String fileName) |
Returns true if the fileName matches any of the wildcard (glob) patterns in the list of filters; otherwise returns false. | |
Boolean | match (String filter, String fileName) |
Returns true if the fileName matches the wildcard (glob) pattern filter; otherwise returns false. | |
void | refresh () |
Refreshes the directory information. | |
String | relativeFilePath (String fileName) |
Returns the path to fileName relative to the directory. | |
Boolean | remove (String fileName) |
Removes the file, fileName. | |
Boolean | removeDirectory (String dirName) |
Removes the directory specified by dirName. | |
Boolean | removePath (String dirPath) |
Removes the directory path dirPath. | |
Boolean | rename (String oldName, String newName) |
Renames a file or directory from oldName to newName. | |
String | toNativeSeparators (String pathName) |
Returns pathName with the '/' separators converted to separators that are appropriate for the underlying operating system. |
Properties | |
String | absolutePath |
Returns the absolute path (a path that starts with "/" or with a drive specification), which may contain symbolic links, but never contains redundant ".", ".." or multiple separators. | |
String | canonicalPath |
Returns the canonical path, i.e. a path without symbolic links or redundant "." or ".." elements. | |
Number | count |
Returns the total number of directories and files in the directory. | |
String | currentPath |
Gets or sets the current path. | |
String | directoryName |
Returns the name of the directory. | |
Array | drives |
Returns a list of the root directories on this system. | |
Boolean | exists |
Returns true if the directory exists; otherwise returns false. | |
Filter | filter |
Gets or sets the filter used by entryList() and entryInfoList(). | |
String | homePath |
Returns the absolute path of the user's home directory. | |
Boolean | isAbsolute |
Returns true if the directory's path is absolute; otherwise returns false. | |
Boolean | isReadable |
Returns true if the directory is readable and we can open files by name; otherwise returns false. | |
Boolean | isRelative |
Returns true if the directory path is relative; otherwise returns false. | |
Boolean | isRoot |
Returns true if the directory is the root directory; otherwise returns false. | |
Array | nameFilters |
Gets or sets the name filters used by entryList() and entryInfoList(). | |
String | path |
Gets or sets the path of the Directory object. | |
String | rootPath |
Returns the absolute path of the root directory. | |
String | separator |
Returns the native directory separator: "/" under Unix (including Mac OS X) and "\" under Windows. | |
Sort | sorting |
Gets or sets the sort order used by entryList() and entryInfoList(). | |
String | tempPath |
Returns the absolute path of the system's temporary directory. |
The Directory class provides access to directory structures and their contents.
A Directory object is used to manipulate path names, access information regarding paths and files, and manipulate the underlying file system.
The Directory class uses "/" as a universal directory separator in the same way that "/" is used as a path separator in URLs. If you always use "/" as a directory separator, the Directory class will translate your paths to conform to the underlying operating system.
A Directory object can point to a file using either a relative or an absolute path. Absolute paths begin with the directory separator (optionally preceded by a drive specification under Windows). Relative file names begin with a directory name or a file name and specify a path relative to the current directory.
enum Filter |
Describes the filtering options available to Directory; e.g. for entryList() and entryInfoList().
The filter value is specified by combining values from the following list using the bitwise OR operator:
enum Sort |
Describes the sort options available to Directory, e.g. for entryList() and entryInfoList().
The sort value is specified by combining values from the following list using the bitwise OR operator. You can only specify one of the first four. If you specify both DirectoriesFirst and Reversed, directories are still put first, but in reverse order; the files will be listed after the directories, again in reverse order.
Directory | ( | String | path, |
String | nameFilter, | ||
Sort | sort = Sort(Name|IgnoreCase) , |
||
Filter | filter = AllEntries |
||
) |
Constructs a Directory object with specified path, that filters its entries by name using nameFilter and by attributes using filter. It also sorts the names using sort.
The default nameFilter is an empty string, which excludes nothing; the default filters is AllEntries, which also means exclude nothing. The default sort is Name | IgnoreCase, i.e. sort by name case-insensitively.
If path is an empty string, Directory uses "." (the current directory). If nameFilter is an empty string, Directory uses the name filter "*" (all files).
Note that path need not exist.
String absoluteFilePath | ( | String | fileName | ) |
Returns the absolute path name of a file in the directory.
Does not check if the file actually exists in the directory; but see Directory.exists. Redundant multiple separators or "." and ".." directories in fileName are not removed (see cleanPath()).
Boolean changeDirectory | ( | String | dirName | ) |
Changes the Directory object's directory to dirName.
Note that the logical cd() operation is not performed if the new directory does not exist. Calling cd("..") is equivalent to calling cdUp().
Boolean changeDirectoryUp | ( | ) |
Changes directory by moving one directory up from the Directory object's current directory.
Note that the logical changeDirectoryUp() operation is not performed if the new directory does not exist.
String cleanPath | ( | String | path | ) |
Removes all multiple directory separators "/" and resolves any "." or ".." found in the path.
Symbolic links are kept. This function does not return the canonical path, but rather the simplest version of the input. For example, "./local" becomes "local", "local/../bin" becomes "bin" and "/local/usr/../bin" becomes "/local/bin".
Returns a list of FileInformation objects for all the files and directories in the directory, ordered according to the name and attribute filters previously set with the nameFilters and filter properties, and sorted according to the flags set with the sorting property.
The name filter, file attribute filter, and sorting specification can be overridden using the nameFilters, filters, and sort arguments.
Returns an empty list if the directory is unreadable, does not exist, or if nothing matches the specification.
Returns a list of FileInformation objects for all the files and directories in the directory, ordered according to the name and attribute filters previously set with the nameFilters and filter properties, and sorted according to the flags set with the sorting property.
The attribute filter and sorting specifications can be overridden using the filters and sort arguments.
Returns an empty list if the directory is unreadable, does not exist, or if nothing matches the specification.
Returns a list of the names of all the files and directories in the directory.
The list is ordered according to the name and attribute filters previously set with the nameFilters and filter properties. The list is also sorted according to the flags set with the sorting property.
The attribute filter and sorting specifications can be overridden using the filters and sort arguments.
Note: To list symlinks that point to non existing files, System must be passed to the filter.
Returns an empty list if the directory is unreadable, does not exist, or if nothing matches the specification.
Returns a list of the names of all the files and directories in the directory.
The list is ordered according to the name and attribute filters previously set with the nameFilters and filter properties. The list is also sorted according to the flags set with the sorting property.
The name filter, file attribute filter and sorting specification can be overridden using the nameFilters, filters, and sort arguments.
Returns an empty list if the directory is unreadable, does not exist, or if nothing matches the specification.
Boolean exists | ( | String | name | ) |
Returns true if the file called name exists; otherwise returns false.
Unless name contains an absolute file path, the file name is assumed to be relative to the current directory.
String filePath | ( | String | fileName | ) |
Returns the path name of a file in the directory.
Does not check if the file actually exists in the directory; but see Directory.exists. If the Directory object is relative, the returned path name will also be relative. Redundant multiple separators or "." and ".." directories in fileName are not removed (see cleanPath()).
String fromNativeSeparators | ( | String | pathName | ) |
Returns pathName using '/' as file separator.
On Windows, for instance, fromNativeSeparators("c:\\winnt\\system32") returns "c:/winnt/system32". The returned string may be the same as the argument on some operating systems, for example on Unix.
Boolean makeAbsolute | ( | ) |
Converts the directory path to an absolute path.
If it is already absolute nothing happens.
Boolean makeDirectory | ( | String | dirName | ) |
Creates a sub-directory called dirName.
Boolean makePath | ( | String | dirPath | ) |
Creates the directory path dirPath.
The function will create all parent directories necessary to create the directory.
Boolean match | ( | Array | filters, |
String | fileName | ||
) |
Returns true if the fileName matches any of the wildcard (glob) patterns in the list of filters; otherwise returns false.
The matching is case insensitive.
Boolean match | ( | String | filter, |
String | fileName | ||
) |
Returns true if the fileName matches the wildcard (glob) pattern filter; otherwise returns false.
The filter may contain multiple patterns separated by spaces or semicolons. The matching is case insensitive.
Boolean remove | ( | String | fileName | ) |
Removes the file, fileName.
Boolean removeDirectory | ( | String | dirName | ) |
Removes the directory specified by dirName.
The directory must be empty for removeDirectory() to succeed.
Boolean removePath | ( | String | dirPath | ) |
Removes the directory path dirPath.
The function will remove all parent directories in dirPath, provided that they are empty. This is the opposite of makePath(dirPath).
Boolean rename | ( | String | oldName, |
String | newName | ||
) |
Renames a file or directory from oldName to newName.
On most file systems, rename() fails only if oldName does not exist, if newName and oldName are not on the same partition or if a file with the new name already exists. However, there are also other reasons why rename() can fail. For example, on at least one file system rename() fails if newName points to an open file.
String toNativeSeparators | ( | String | pathName | ) |
Returns pathName with the '/' separators converted to separators that are appropriate for the underlying operating system.
On Windows, toNativeSeparators("c:/winnt/system32") returns "c:\winnt\system32". The returned string may be the same as the argument on some operating systems, for example on Unix.
|
read |
Returns the canonical path, i.e. a path without symbolic links or redundant "." or ".." elements.
On systems that do not have symbolic links this function will always return the same string that absolutePath returns. If the canonical path does not exist (normally due to dangling symbolic links) canonicalPath returns an empty string.
|
read |
Returns the total number of directories and files in the directory.
Equivalent to entryList().length.
|
read |
Returns the name of the directory.
A directory name isn't the same as the path, e.g. a directory with the name "mail", might have the path "/var/spool/mail". If the directory has no name (e.g. it is the root directory) an empty string is returned.
No check is made to ensure that a directory with this name actually exists; but see Directory.exists.
|
read |
Returns a list of the root directories on this system.
On Windows this returns a list of FileInformation objects containing "C:/", "D:/", etc. On other operating systems, it returns a list containing just one root directory (i.e. "/").
|
read |
Returns true if the directory exists; otherwise returns false.
If a file with the same name is found this function will return false.
|
readwrite |
Gets or sets the filter used by entryList() and entryInfoList().
The filter is used to specify the kind of files that should be returned by entryList() and entryInfoList().
|
read |
Returns the absolute path of the user's home directory.
Under Windows this function will return the directory of the current user's profile. Typically, this is: C:/Documents and Settings/Username
Use the toNativeSeparators() function to convert the separators to the ones that are appropriate for the underlying operating system.
If the directory of the current user's profile does not exist or cannot be retrieved, the following alternatives will be checked (in the given order) until an existing and available path is found:
Under non-Windows operating systems the HOME environment variable is used if it exists, otherwise the path returned by the rootPath() function is used.
|
read |
Returns true if the directory is readable and we can open files by name; otherwise returns false.
Warning: A false value from this function isn't a guarantee that files in the directory are not accessible.
|
read |
Returns true if the directory is the root directory; otherwise returns false.
Note: If the directory is a symbolic link to the root directory this function returns false. If you want to test for this use canonicalPath.
|
readwrite |
Gets or sets the name filters used by entryList() and entryInfoList().
Each name filter is a wildcard (globbing) filter that understands * and ? wildcards.
|
readwrite |
Gets or sets the path of the Directory object.
The path is cleaned of redundant ".", ".." and of multiple separators. No check is made to see whether a directory with this path actually exists; but you can check for yourself using exists().
The path can be either absolute or relative. Absolute paths begin with the directory separator "/" (optionally preceded by a drive specification under Windows). Relative file names begin with a directory name or a file name and specify a path relative to the current directory. An example of an absolute path is the string "/tmp/quartz", a relative path might look like "src/fatlib".
|
read |
Returns the absolute path of the root directory.
For Unix operating systems this returns "/". For Windows file systems this normally returns "c:/".
|
read |
Returns the native directory separator: "/" under Unix (including Mac OS X) and "\" under Windows.
You do not need to use this function to build file paths. If you always use "/", the Directory class will translate your paths to conform to the underlying operating system. If you want to display paths to the user using their operating system's separator use toNativeSeparators()
|
read |
Returns the absolute path of the system's temporary directory.
On Unix/Linux systems this is usually /tmp; on Windows this is usually the path in the TEMP or TMP environment variable. Whether a directory separator is added to the end or not, depends on the operating system.