Plugins/File Operations

From EventGhost
Jump to: navigation, search
Plugin Information
Name File Operations
Authors Pako
Current Version1 0.1.7
Official Website N/A
Forum Page [1]
Source Code [2]
Type General
Source Bundled
Minimum EventGhost Version N/A

1 This is the current version as of this page's last update. Newer versions may be available.

This wiki page may be out of date. Always consult the above website and forum links for possibly updated information.

This plugin can be used to read in a file, write to a file, or periodically read a file.

Overview

Basic Reading and Writing

At its simplest, you can use this plugin to read text from a file, and/or write text out to a file.

Writing text to a file can be a useful way of recording a log of activities.

You can read a file and then immediately write its contents to a new file, or even the same file. You could do this if you wanted to change the character encoding of the file.


Periodical Reading

This plugin also allows you to periodically read a text file, and perform some action with its contents. One possible use of this action is to observe the log file that is created by another program, and react when a new message appears in the log file (for example, flashing it on the screen via Action.pngShow OSD).

Configuration

This plugin is not directly configured from its dialog. However, double-clicking the plugin will give you a list of all the files it is currently watching.

Events

For all of the following events, the payload is a tuple whose only element is the complete path to the file or directory which caused the event to be generated.

Event Payload? Enduring? Description
Event.pngFile.* Y N Triggered whenever a file (which you've configured using Action.pngStart Periodical Reading is re-read. The The event suffix is what you specified when you configured the event, and the payload is the contents that were read from the file.


Actions

Read Text From File

Setting Default {·} Description
Read File (no default) Y The file you wish to read text from.
Input data coding Your current Windows system code page N What character encoding the named file is created in.
Error handling during decoding Raise an exception N How to behave if the file doesn't seem to be correctly coded in the encoding you chose. The default action (raise an exception) will stop your macro. You can also choose to ignore, or replace, characters which are invalid in your chosen input encoding.
Read # lines 1 N The number of lines to read from the file. If you enter 0, the whole file will be read.
Start at line number 1, from the beginning N Which line to start reading from, counting from either the beginning or end of the file.
Line(s) return like as a String without CR/LF N If reading one line, whether to include the carriage return and line feed that's found at the end of each line, or to strip it off (the default). If reading more than one line, whether to return them as a list (with or without the carriage return and line feed on each line), or as a string (with carriage returns and line feeds).

This action reads text from the file you specify, at the time the macro containing it is run. The line(s) of text are returned in eg.result for use by the next step in your macro.


Start Periodical Reading

Setting Default {·} Description
Read File (no default) Y The file you wish to read text from.
Input data coding Your current Windows system code page N What character encoding the named file is created in.
Error handling during decoding Raise an exception N How to behave if the file doesn't seem to be correctly coded in the encoding you chose. The default action (raise an exception) will stop your macro. You can also choose to ignore, or replace, characters which are invalid in your chosen input encoding.
Read # lines 1 N The number of lines to read from the file. If you enter 0, the whole file will be read.
Start at line number 1, from the beginning N Which line to start reading from, counting from either the beginning or end of the file.
Line(s) return like as a String without CR/LF N If reading one line, whether to include the carriage return and line feed that's found at the end of each line, or to strip it off (the default). If reading more than one line, whether to return them as a list (with or without the carriage return and line feed on each line), or as a string (with carriage returns and line feeds).
Observation and event name (no default) Y Events generated by this action will have this text as their suffix. You will also use this text in a future Action.pngAbort Periodical Reading action, to stop watching this file.
Event trigger Always if not empty N Whether the event should be triggered always, always if the file has content (the default), only if the file has changed, or only if the file has changed and has content.

When this action is triggered, EventGhost will start watching the specified file, and at each interval you specify (once per second is the default), it will trigger an event as listed above.

EventGhost will continue watching the file forever, even after your macro completes, until you either abort watching it with one of the below events, or you double-click the plugin in your Autostart.pngAutostart and abort it from there.


Abort Periodical Reading

Setting Default {·} Description
Observation and event name (no default) Y The event suffix you specified in Action.pngStart Periodical Reading.

When this action runs, it causes EventGhost to stop watching the file which corresponds to the event name you specified.


Abort All Periodical Reading

When this action runs, it causes EventGhost to stop watching all files it is currently watching.

Write Text To File

Setting Default {·} Description
Input Text {eg.result} Y The text you wish to write to a file.
Output file EG_WTTF.txt Y The file to which you wish to write the text.
Output data coding Your current Windows system code page N What character encoding you wish to use when creating/appending the file.
Error handling during encoding Raise an exception N How to behave if the text can't be encoded in the encoding you chose. The default action (raise an exception) will stop your macro. You can also choose to ignore, or replace, characters which are invalid in your chosen output encoding.
Mode of write Append to file with new line N Whether to replace the file (if it exists) with your text, append your text to the end of the file, or append your text and follow it with a carriage return and line feed (the default).
Write to EventGhost log too False N Whether to record the text being written in the EventGhost log window.
Write Timestamp False N If you check this, the current date and time (in the format YY-MM-DD HH:MM:SS) will be written to the file before your text is added.
String write in the HexDump form False N If you check this, the string will be converted to its hexadecimal code points, and each code point will be written with a space between them.

This action takes the text you specify, and writes it out to the file you specify.


See Also