Files
🔗 Original page — Source of this material
Description
ZennoPoster allows you to automate working with files.
Where can this be used?
- Insert prepared text from a file when posting on forums,
- Placing ads on various websites,
- Adding automatic comments,
- Write data to files when parsing websites,
- Keep detailed logs in a file,
- Delete or move unnecessary files.
How to add an action to your project?
Via the context menu Add Action → Data→ Files

Or use the ❗→ Smart Search.
How to work with this action?

The following actions for working with files are available, which can be selected in the properties window:
Get Text

Copying text from a file, with an option to save it to a variable.
File path
Here, you need to specify the path to the file from which the data will be read.
You can use variable macros.
Delete file after reading
After the action is performed, the file will be deleted.
Write Text

Add text to a file.
What to write
The text you want to write to the file.
You can use variable macros.
Append to file
If this option is enabled, the text you specify will be added to the end of the file. If unchecked, the file will be completely overwritten with your text.
Add line break at the end
A line break (\r\n) will be added to the end of your text after it's written to the file. This is necessary for more correct writing of multiple lines of data to a file.
When working in multithreaded mode, it is recommended to use a List and write lines to a file using the List Operations action.
Move
This moves a file to the specified directory. This option can also be used to rename a file.
You need to specify the full path to an existing file, as well as the desired path and new filename after moving.

Check Existence
Checks if a file exists at the specified path.
- If the file exists – green (success) output, if not – red (fail) output;
- Timeout – how long the action will wait for the file to appear, in seconds.
Copy
Similar to moving, but the original file is not deleted.
Delete
Deletes a file at the specified path.
Possible practical uses
Let's set the following task:
- Download an image from vk.com
- Rename it
- Move it to the desired folder
Suppose you already have a direct link to the image: https://sun9-71.userapi.com/zcp0gi3hCgW39FmT3J7vsAiawigKHI_WP4J5YA/fWlAmX-lUM8.jpg
Using a ❗→ GET request, download the image to your computer. Use PicPath as the variable. After this action, the specified variable will contain the direct file path to the image:

Next, create a “Random” action to generate a filename. More on Random here: ❗→ Random numbers and strings (Random)

Now, create a “Files” action and select the “Move” option.

For the "File path" field, specify: { -Variable.PicPath- };
For the "New path" field: { -Project.Directory- }Полицейский\{ -Variable.name_file- }.jpg
{ -Project.Directory- } is a macro that uses the directory where your project is located (read more about this and other macros ❗→ here).
After this action is completed, the file will be moved to the desired folder and you can upload the next image.
When working with images, make sure to use the same file extension that was used when downloading.
To get the file extension, you can use the ❗→ Text Processing action and regular expressions. More details: ❗→ Regular Expression Tester