How-tos: Files

Moving files to a network folder

Description

We can save a lot of time by automating the process of moving files — and we can do that all across our internal network. In this article you find two methods to move a file from one folder to another.

Instructions

Method #1

  1. Add the Move file activity
  1. In the "Path" option, choose "Set a value" and insert the file path
  1. Run the workflow.

Method #2

Add the Command Prompt activity

  1. Inside the Command Prompt in the option command, add the following syntax: move "%USERPROFILE%\Move_file\test.txt" "%USERPROFILE%\Move_file\destiny"
  • Replace the "%USERPROFILE%\Music\howto\Move_file\test.txt" with your file path
  • Replace the %USERPROFILE%\Music\howto\Move_file\destiny with your destiny folder path
  1. Run the workflow — and it's done!

🚧

Note

This Methods works for network folders that are mapped in your system.

⬅️

Back to the table


Uploading Files via FTP/HTTP

Description

The File Transfer Protocol (FTP) is an application we can use to transfer of files from one computer to another — or, basically, any device in the world that is connected to the Internet. In this article, you will learn how to upload a file to an FTP server using Studio Pro.

Instructions

In this example, we use cURL, a program that you can access through the terminal (CMD) using the Command Prompt activity of Studio Pro. To do so, follow these steps:

  1. Use the Command Prompt activity located in OS Automation/System

  2. Select the “Calculate a value” option and enter the following command:

curl -s -T [LOCAL_FILE] ftp://[FTP_HOSTNAME]/[FTP_DIRECTORY_PATH]

Bear in mind that:

  • [LOCAL_FILE] is the file you want to upload to the FTP Server.
  • [FTP_HOSTNAME] is the name of the server you want to work with.
  • [FTP_DIRECTORY_PATH] is the directory in the FTP Server where you want to upload the [LOCAL_FILE].

For example, a complete upload file to FTP command would look like this:

curl -s -T test_photo.png ftp://ftp.example.com/dir/path/

This way you can upload any file to the desired FTP server just using the [LOCAL_FILE] as a variable.
Now, if you want to upload multiple files at the same time, do the following:

curl -s -T 'image[1-99].jpg' ftp://ftp.example.com/upload/

1curl -s -T '{Huey,Dewey,Louie}.jpg' ftp://ftp.example.com/nephews/

Complete detail about the cURL program can be found on cURL - How To Use.

📘

Note

It’s important to add the “-s” parameter in order to cURL work properly with Studio Pro.

⬅️

Back to the table


Managing Files Paths

Description

When uploading a bot to Orchestrator using files existing on a machine, the paths to these files cannot be relative paths. Otherwise, when Bot Runner runs a bot, it looks for files in locations impossible to access from that device.

In this article, you will learn how to run workflows from different a machine when they need to interact with files locally saved.

Notice that you can also use these instructions if you face a "File not found" error message in the logs.

Instructions

To ensure that bots run as expected, always use full paths to any needed files. This works for normal paths or UNC paths as long as they are full paths and not relative ones. Here's what we need to do:

  1. When using an activity, into the "Directory path", click "Set value" and then enter the full directory path as shown in the following screenshot.

  1. Another option is to select the UNC path as in the image below.

🚧

Note

If the file path is entered only with the file name, the Bot Runner will look for this file in the directory where Bot Runner is installed. Look at this example

Related articles

Any activities that reference a file path would need to be set up in this manner. This includes, for example, Excel Activities and OS Automation Activities.

⬅️

Back to the table


How to work with folders in Windows

In this article you'll learn how to create folders, list their content and delete them.

Instructions

  1. Add the "Create directory" activity to your workflow.
  1. Add the following configuration:
  1. To list the contents of the created directory, include a "List directory files" activity. Save the result in a variable named "directory_files".
  1. In order to delete this folder, add the “Command prompt” activity with the command: rmdir C:\test\test1.

📘

Note

Keep in mind that this command can only remove empty folders. If the folder holds files or subfolders, these must be deleted before you can remove the folder itself.

  1. The final result will look like this:

⬅️

Back to the table


How to rename a file

Instructions

  1. Add the Move File activity to your workflow.
  2. Use the Pick button to indicate the the path of the file to be renamed.
  3. Check the "Replace already existing file" option.

📘

Note

Dynamic paths, are declared using the "calculate a value" option.

🚧

Caution

  • Be cautios when working Javascript escape sequences.

  • Caution: Avoid changing the file extension while renaming.

⬅️

Back to the table