Skip to main content

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 ActionDataFiles

image-20200804-135020

Or use the ❗→ Smart Search.

How to work with this action?

image-20200804-135044

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

Get Text

image-20200804-135203

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.

Note

You can use variable macros.

Delete file after reading

After the action is performed, the file will be deleted.

Write Text

image-20210516-161258

Add text to a file.

What to write

The text you want to write to the file.

Note

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.

Info

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.

Note

You need to specify the full path to an existing file, as well as the desired path and new filename after moving.

image-20200804-135849

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:

  1. Download an image from vk.com
  2. Rename it
  3. 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:

image-20200804-151938

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

image-20200804-152317

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

image-20200804-152355

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.

Warning

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