In UiPath Studio development, we often manipulate files and folders.
However, it can be difficult to know which activity to use for what you want to achieve.
This article explains how to get a list of files in a folder, rename or move files and open files, and create or open folders.
\Save during the sale period!/
Take a look at the UiPath course on the online learning service Udemy
*Free video available
Related Articles Learn the Creation Techniques f UiPath robotics creation with Udemy’s online courses that take it up a notch
This site was created by translating a blog created in Japanese into English using the DeepL translation.
Please forgive me if some of the English text is a little strange
Get the file name
Get the list of files in the specified folder.
System.IO.Directory.GetFiles(“<folder path>”) is used to get a list of files in a specific folder.
Get the list of files in the specified folder and output the full path, file name only, and file name without extension to the log.
・Code for the parts that are not fully displayed
The [Assign File List] activity will
arrFileFullPath = System.IO.Directory.GetFiles("C:\work\50_system\UiPath\ENG\FileList")
The [Assign FileName] activity will
strFile = System.IO.Path.GetFileName(strFilePath)
The [Assign FIleName No Extension] activity will
strFilewithout = System.IO.Path.GetFileNameWithoutExtension(strFilePath)
Each function has a
- [System.IO.Directory.GetFiles] gets the full path to the files in the first argument, the target folder path.
- [System.IO.Path.GetFileName] gets the file name with extension from the full path file name of the first argument.
- [System.IO.Path.GetFileNameWithoutExtension] gets the file name without extension from the full path file name of the first argument
・Variables
・target folder
・Execution result
Retrieve only specific file names in a specified folder.
System.IO.Directory.GetFiles(“<FolderPath>”, “<search string>”) is used to get the specific file name in the list of files in a specific folder.
Acquire only file names that contain the specified string in the file list of the specified folder, and output the full path, file name only, and file name without extension to the log.
・Code for the parts that are not fully displayed
The [Assign FIleList] activity will
arrFileFullPath = System.IO.Directory.GetFiles("C:\work\50_system\UiPath\ENG\FileList","*.xlsx")
The [Assign FileName] activity will
strFile = System.IO.Path.GetFileName(strFilePath)
The [Assign FileName No extention] activity will
strFilewithout = System.IO.Path.GetFileNameWithoutExtension(strFilePath)
Each function has a
- [System.IO.Directory.GetFiles] searches for files in the first argument’s target folder path with the second argument and gets the full path.
* The second argument, *, represents an arbitrary string. - [System.IO.Path.GetFileName] gets the file name with extension from the full path file name of the first argument.
- [System.IO.Path.GetFileNameWithoutExtension] gets the file name without extension from the full path file name of the first argument
・Variables
・target folder
・Execution result
File operation
Move files(Move File)
To move a file, use “Move File”.
“Move File” is located in System > File.
Move File Setting item
Setting location | Setting item | Setting contents | |
Body
|
From | The path of the file to be moved. | |
To | The destination path where the file is to be moved. | ||
Overwrite | When checked, overwrites the files in the destination folder with the file that is to be copied. | ||
Properties | Common | DisplayName | The display name of the activity. |
ContinueOnError | Specifies if the automation should continue even when the activity throws an error. | ||
Misc | Private | If selected, the values of variables and arguments are no longer logged at Verbose level. | |
To | Destination | The destination path where the file is to be moved. | |
From | Path | The path of the file to be moved. | |
Options | Overwrite | When checked, overwrites the files in the destination folder with the file that is to be copied. |
Move the file.
・Move File Properties
・Folder before process execution
・Folder after executing the process
Rename the file(Move File)
To rename a file, use “Move File”.
“Move File” is located in [System > File].
Move File Setting item
Setting location | Setting item | Setting contents | |
Body
|
From | The path of the file to be moved. | |
To | The destination path where the file is to be moved. | ||
Overwrite | When checked, overwrites the files in the destination folder with the file that is to be copied. | ||
Properties | Common | DisplayName | The display name of the activity. |
ContinueOnError | Specifies if the automation should continue even when the activity throws an error. | ||
Misc | Private | If selected, the values of variables and arguments are no longer logged at Verbose level. | |
To | Destination | The destination path where the file is to be moved. | |
From | Path | The path of the file to be moved. | |
Options | Overwrite | When checked, overwrites the files in the destination folder with the file that is to be copied. |
Rename the file.
・Move File Properties
・The target folder before the process is executed
・The target folder after the process is executed
open a file(Start Process)
Use “Start Process” to open the specified file.
The “Start Process” is located in [System > Application].
Start Process Setting item
設定場所 | 設定項目 | 設定内容 | |
Body
|
FileName | The full file path where you can find the executable file of the application to be opened. | |
Arguments | The parameters that can be passed to the application at startup. | ||
Properties | Common | DisplayName | The display name of the activity. |
ContinueOnError | Specifies if the automation should continue even when the activity throws an error. | ||
Misc | Private | If selected, the values of variables and arguments are no longer logged at Verbose level. | |
Input | FileName | The full file path where you can find the executable file of the application to be opened. | |
WorkingDirectory | Path of the current working directory. | ||
Arguments | The parameters that can be passed to the application at startup. |
Open the specified file.
・Start Process Properties
・Target file
・Execution result
Folder Operations
Create a folder(Create Folder)
To create a new folder, use “Create Folder”.
“Create Folder” is located in [System > File].
Create Folder Setting item
設定場所 | 設定項目 | 設定内容 | |
Body
|
Folder name | The full path of the directory to be created. | |
Properties | Common | DisplayName | The display name of the activity. |
ContinueOnError | Specifies if the automation should continue even when the activity throws an error. | ||
Misc | Private | If selected, the values of variables and arguments are no longer logged at Verbose level. | |
In folder | Path | The full path of the directory to be created. |
Create a new folder.
・Create Folder Properties
・Target folder before process execution
・Target folder after executing the process
Open the folder(Start Process)
Use “Start Process” to open the folder.
The “Start Process” can be found under [System > Application].
Start Process Setting item
設定場所 | 設定項目 | 設定内容 | |
Body
|
FileName | The full file path where you can find the executable file of the application to be opened. | |
Arguments | The parameters that can be passed to the application at startup. | ||
Properties | Common | DisplayName | The display name of the activity. |
ContinueOnError | Specifies if the automation should continue even when the activity throws an error. | ||
Misc | Private | If selected, the values of variables and arguments are no longer logged at Verbose level. | |
Input | FileName | The full file path where you can find the executable file of the application to be opened. | |
WorkingDirectory | Path of the current working directory. | ||
Arguments | The parameters that can be passed to the application at startup. |
Open the specified folder.
・Start Process Properties
・Execution result
The folder path specified in Arguments will be opened.
summary
- System.IO.Directory.GetFiles(“<FolderPath>”) is used to get the list of files in the specified folder.
- To move or rename a file, use “Move File”.
- Use “Start Process” to open the specified file or folder.
- To create a new folder, use “Create Folder”.
\Save during the sale period!/
Take a look at the UiPath course on the online learning service Udemy
*Free video available
Related Articles Learn the Creation Techniques f UiPath robotics creation with Udemy’s online courses that take it up a notch
same category UiPath
Japanese IT engineer with a wide range of experience in system development, cloud building, and service planning. In this blog, I will share my know-how on UiPath and certification. profile detail / twitter:@fpen17