Get name action

The Get name action in the File package enables you to get the name and the extension of the file.

Settings

Do the following steps to retrieve the file name and extension:
  1. In the Source file tab, select one of the following options to specify the location of your file:
    • Control Room file: Enables you to select the file that is available in a folder in the Control Room.
    • Desktop file: Enables you to select the file that is available on your device.
    • Variable: Enables you to specify the file variable that contains the location of the file.
  2. In the Save the outcome to a variable field, select a string variable to save the output.

Example

In this example you will build a bot to retrieve the file name and extension. The output generated by this action enables you to execute further actions, such as, splitting the file name and extension separately for using it in your bot.
  1. Create a bot.
    1. On the left panel, click Automation.

      A list of available bots and forms is displayed.

    2. Click Create a bot.
    3. Enter the bot name: File_getname
    4. Click Create and Edit.
  2. To retrieve the name of a specified file, double-click or drag the File > Get name action.
    1. In the Source file field, select the Desktop file option and select the file path C:\Bot testing\File pkg\API.docx that you created in the folder.
    2. In the Save the outcome to a variable field, click the Create variable icon to create a variable.
    3. On the Create variable window, enter Filename_output in the Name field.
  3. To print the values, double-click or drag the Message box action. In the Enter the message to display field, enter $Filename_output$.

    When you run the bot, the bot displays the output as follows:

    Output from Get name action

  4. To split and extract the file name and extension separately, double-click or drag the String > Split action.
    1. In the Source string field, enter $Filename_output$
    2. In the Delimiter field, enter .
    3. From the Delimiter is tab, select Not case sensitive.
    4. From the Split into substrings tab, select All possible.
    5. In the Assign value to the variable field, click the Create variable icon to create a variable.
    6. On the Create variable window, enter Filesplit_output in the Name field.
    7. Click Create and select.
  5. To print the values of the file name and extension, double-click or drag the Message box action. In the Enter the message to display field, enter the following data:

    File name is $Filesplit_output[0]$

    File extension is $Filesplit_output[1]$

  6. Click Save and then Run.

    The bot splits the file name and extension values separately and displays the output as follows:

    Split the file name and extension values separately