Nilesoft Shell Pro GitHub

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. Returns true when it was moved. A relative path starts from the folder the menu was opened in.

By default a file can move to another drive, and a file already at the new path is kept (the move fails). A directory can only move within its drive.

Syntax

io.move(oldPath, newPath)
io.move(oldPath, newPath, flags)
flags:
1 = replace an existing file, 2 = allow a move to another drive, 8 = finish writing to the disk before returning
default = 2

Example:
io.move(sel.path, path.combine('D:\backup', sel.name), 1 | 2)
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)
io.delete(sel)
io.delete(path1, path2, ...)
io.delete([path1, path2, ...])

To delete several things at once, give io.delete the whole selection with sel, or list the paths one after another, or put them in a list with square brackets. Each one is deleted, and the result is true only if all of them were deleted.

sel means everything the user selected, so files, folders or a mix all work. There is no confirmation, so use it with care. Nothing happens when the menu is opened on the empty background of a folder, because then there is no selection to delete.

When more than one path is given, folders are deleted with everything in them. Add false at the end to delete only empty folders instead.


Examples:
io.delete('C:\Temp\old-logs', true)
io.delete('C:\Temp\a.txt', 'C:\Temp\b.txt')

A menu item that deletes whatever files and folders are selected, without asking:
item(title='Delete selection' mode='multiple' cmd=io.delete(sel))
io.directory.create (io.dir.create)

Create new directory.

When one new folder is made in the folder that File Explorer, the desktop, or an Open or Save box is showing, it is selected and its name is ready to edit, the same as Windows' New menu does. This happens whether you give its name or its full path. A folder made anywhere else, or several folders from one io.dir.create, are only created.

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 works when the file is made in the folder that File Explorer, the desktop, or an Open or Save box is showing, given by its name (for example 'new.txt') or by its 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"))