Get name action
- Updated: 2022/11/14
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:
- 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.
- 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.
- Create a bot.
- On the left panel, click Automation.
A list of available bots and forms is displayed.
- Click Create a bot.
- Enter the bot name: File_getname
- Click Create and Edit.
- On the left panel, click Automation.
- To retrieve the name of a specified file, double-click or drag the action.
- 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.
- In the Save the outcome to a variable field, click the Create variable icon to create a variable.
- On the Create variable window, enter Filename_output in the Name field.
- 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:
- To split and extract the file name and extension separately, double-click or drag
the action.
- In the Source string field, enter $Filename_output$
- In the Delimiter field, enter .
- From the Delimiter is tab, select Not case sensitive.
- From the Split into substrings tab, select All possible.
- In the Assign value to the variable field, click the Create variable icon to create a variable.
- On the Create variable window, enter Filesplit_output in the Name field.
- Click Create and select.
- 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]$
- Click Save and then Run.
The bot splits the file name and extension values separately and displays the output as follows: