IO
io.attribute enumerations.
Syntax
io.attribute.archive
io.attribute.compressed
io.attribute.device
io.attribute.directory
io.attribute.encrypted
io.attribute.hidden
io.attribute.invalid
io.attribute.normal
io.attribute.offline
io.attribute.readonly
io.attribute.sparsefile
io.attribute.system
io.attribute.temporary
io.attribute.virtual
io.attributes
Retrieves file system attributes for a specified path.
Syntax
io.attributes(path)attribute verification
// check if path is hidden
io.attribute.hidden(path)
// check if path is directory
io.attribute.directory(path)
var { atrr = io.attributes(path) }
// check if attr is hidden
io.attribute.hidden(atrr)
// check if attr is directory
io.attribute.directory(atrr)
io.copy
Copies an existing file to a new file.
Syntax
io.copy(pathFrom, pathTo)
io.copy(pathFrom, pathTo, options)
options:1 = skip_existing, 2 = overwrite_existing, 4 = update_existing, 16 = recursive
default = update_existing | recursive
Example:
io.copy('c:\old', 'd:\new', 16 | 4)
io.move
Moves an existing file or a directory, including its children..
Syntax
io.move(oldPath, newPath)
io.rename
Rename a file or directory.
Syntax
io.rename(oldName, newName)
io.delete
Deletes a file or a folder. Returns true if the path was deleted.
By default a folder is deleted only when it is empty. Pass true (or 1) as the second argument to delete the folder with everything in it. Items are deleted permanently, not moved to the Recycle Bin.
With the second argument, the path must be a full path, and a drive or network share root is never deleted. Links (symbolic links, junctions) are not followed: the link itself is deleted and the folder it points to is left alone.
Syntax
io.delete(path)io.delete(path, recursive)
Example:
io.delete('C:\Temp\old-logs', true)
io.directory.create (io.dir.create)
Create new directory.
Syntax
io.directory.create(path)
io.directory.exists (io.dir.exists)
Check if one or more directories exists.
Syntax
io.directory.exists(path)
io.directory.exists(path1, path2, path3, ...)
io.directory.empty (io.dir.empty)
Check if one or more directory is empty.
Syntax
io.directory.empty(path)
io.directory.empty(path1, path2, path3, ...)
File functions.
io.file.size
Retrieves the size of the specified file, in bytes.
Syntax
io.file.size(path)
io.file.exists
Check if one or more files exists.
Syntax
io.file.exists(path)
io.file.exists(path1, path2, path3, ...)
io.file.read
Read file contents as text with character count option.
Syntax
io.file.read(path)io.file.read(path, 12)
io.file.create
Create new file with content option. If the file already exists, it is replaced.
The optional third argument, when true, selects the new file in the open Explorer window and starts renaming it, the same as Windows' New menu does. This only works when the menu was opened inside an Explorer folder, and the file must be in that folder, given by its name (for example 'new.txt', not a full path). Otherwise the file is still created but not renamed. Pass "" as the content to create an empty file and rename it.
Syntax
io.file.create(path)io.file.create(path, "Hello World!")io.file.create(path, "", true)
io.file.write
Writing to a file with new content.
Syntax
io.file.write(path, "Hello World!")
io.file.append
Appends text to an existing file, or to a new file if the specified file does not exist.
Syntax
io.file.append(path, "Hello ")
io.file.append(path, "World!")
io.datetime
Gets or Sets the time of the file.
Syntax
get date time
io.datetime.created(sel.path)
io.datetime.modified(sel.path)
io.datetime.accessed(sel.path)
io.datetime.created(sel.path, 'y/m/d')
io.datetime.modified(sel.path, 'y/m/d')
io.datetime.accessed(sel.path, 'y/m/d')
set date time
io.datetime.created(sel.path,2000,1,1))
io.datetime.modified(sel.path,2000,1,1))
io.datetime.accessed(sel.path,2000,1,1))
io.meta
Gets meta data by property key.
Syntax
io.meta('path\to\file',"System.Size"))