This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Download Microsoft Edge
More info about Internet Explorer and Microsoft Edge
Important
To prevent unauthorized access, Windows requires administrator rights to access protected files. To access these resources using the file actions, run Power Automate with administrator rights. For more information about running Power Automate as an administrator, go to
Run Power Automate with elevated rights
.
Handling files and their content is essential for most automation scenarios. You can use the file actions to manage files, retrieve their properties, read and write data, and convert them to other types.
Most file actions require paths that specify the files you want to manipulate. These paths can be hard-coded values or
file datatype variables
.
To provide many files as input, use a
list variable
with file items. A method to create a list of files is the
Get files in folder
action.
Similarly, you can populate a hard-coded value or a
folder datatype variable
to specify a destination folder in the actions that need one.
To append text content or overwrite text files, deploy the
Write text to file
action. To read the content of a text file, use the
Read text from file
action.
Likewise, if you need to read or write content to CSV files, use the
Read from CSV file
and
Write to CSV file
actions. You can find an example desktop flow that handles CSV files in
Convert a CSV file into an Excel spreadsheet
.
If you want to check if a file exists in a specific folder, use the
If file exists
action. This action is a conditional and allows you to run different blocks of code depending on whether the file exists. To find more information about conditionals, go to
Use conditionals
.
If file exists
Marks the beginning of a conditional block of actions depending on whether a file exists or not.
Argument
Optional
Accepts
Default Value
Description
This action doesn't produce any variables.
Exceptions
This action doesn't include any exceptions.
Wait for file
Suspend the execution of the automation until a file is created or deleted.
Argument
Optional
Accepts
Default Value
Description
Created, Deleted
Created
Specifies whether to pause the flow on the creation or deletion of a certain file
File path
The full path to look for the file
Variables produced
This action doesn't produce any variables.
Exceptions
This action doesn't include any exceptions.
Copy file(s)
Copy one or more files into a destination folder.
Argument
Optional
Accepts
Default Value
Description
List
of
Files
The file(s) to copy. This value can be a file path, or a variable containing a file, a list of files, a text path, or a list of text paths. Use the 'Get files in folder' action to populate a variable with a list of files.
Destination folder
Folder
The destination folder for the copied files
If file exists
Do nothing, Overwrite
Do nothing
Specifies what to do if a file with the same name already exists in the destination folder
Variables produced
Argument
Description
List
of
Files
The file(s) to move. This value can be a file path, or a variable containing a file, a list of files, a textual path, or a list of text paths. Use the 'Get files in folder' action to populate a variable with a list of files.
Destination folder
Folder
The destination folder for the moved files
If file exists
Do nothing, Overwrite
Do nothing
Specifies what to do if a file with the same name already exists in the destination folder
Variables produced
Argument
Description
List
of
Files
The file(s) to rename. This value can be a file path, or a variable containing a file, a list of files, a text path, or a list of text paths. Use the 'Get files in folder' action to populate a variable with a list of files.
Add number to
Boolean value
Specifies whether to add the number to the existing file name(s) or a new name
Rename scheme
Set new name, Add text, Remove text, Replace text, Change extension, Add datetime, Make sequential
Set new name
Specifies how to rename the file(s)
New file name
Text value
The new name of the file(s)
New extension
Text value
The text to add as the new extension for the file(s)
New file name
Text value
The new name of the file(s)
Add number to
After name, Before name
After name
Specifies whether to add the number before or after the original name(s) or a new base name
Text to add
Text value
The text to add to the original file name(s)
Text to remove
Text value
The text to remove from the original file name(s). This rename scheme searches each file name, and removes the entered text anywhere in the name, each time it occurs.
Text to replace
Text value
The text to replace in the original file name(s). This rename scheme searches each file name, and replaces the entered text anywhere in the name, each time it occurs
Use custom datetime
Boolean value
False
Specifies whether to use a custom datetime
Datetime to add
Current datetime, Creation time, Last accessed, Last modified
Current datetime
Specifies what datetime value to add to the file name(s)
Keep extension
Boolean value
Specifies whether to include the previous extension with the file name(s). Disable this option to add the extension to the file(s) manually.
Replace with
Text value
The text to replace the original text with
Start numbering at
Numeric value
The starting number value
Add text
After name, Before name
After name
Specifies whether to add the text before or after the original name(s)
Custom datetime
Datetime
The datetime to add to the file name(s)
Increment by
Numeric value
The number to increment the starting value by
Add datetime
After name, Before name
After name
Specifies whether to add the datetime before or after the original name(s)
Separator
Nothing, Space, Dash, Period, Underscore
Space
Specifies what to use to separate the original file name and the number added, including the option to not use a separator
Separator
Nothing, Space, Dash, Period, Underscore
Space
Specifies what to use to separate the original file name and the datetime value added, including the option to not use a separator
Use padding
Boolean value
False
Specifies whether to use padding
Datetime format
Text value
yyyyMMdd
The format of the datetime value to add to the file name, such as MM/dd/yyyy for date, and hh:mm:sstt for time
Make each number at least
Numeric value
The minimum length for each number added
If file exists
Do nothing, Overwrite
Do nothing
Specifies what to do if a file with the same name already exists in the folder
Variables produced
Argument
Description
Single text value, List (each is a list item)
Single text value
Specifies how to store the text. Choose 'Single text value' to store the entire text as a single text value. Choose 'List' to store each line of the original text as a text item in a list.
Encoding
System default, ASCII, Unicode, Unicode (big-endian), UTF-8
UTF-8
The encoding to read the specified text from the text file with.
Variables produced
Argument
Description
The file to write the text. This value can be a file path, or a variable containing a file or a textual path.
Text to write
General value
The text to write in the specified file
Append new line
Boolean value
Specifies whether to append a new line at the end of the overall text to write to the file
If file exists
Overwrite existing content, Append content
Overwrite existing content
Specifies whether to overwrite the existing content, or to append to the end of the existing content. If the file doesn't exist, this action automatically creates it.
Encoding
System default, ASCII, Unicode, Unicode (big-endian), UTF-8, Unicode (without byte order mask), UTF-8 (without byte order mask)
Unicode
The encoding to use for the specified text to write into the text file
Variables produced
This action doesn't produce any variables.
Exceptions
Exception
Description
The CSV file to read. This value can be a file path, or a variable containing a file or a textual path
Encoding
UTF-8, Unicode, Unicode (big-endian), UTF-8 (No byte order mark), Unicode (no byte order mark), System default, ASCII
UTF-8
The encoding to be used for reading the specified CSV file
Trim fields
Boolean value
Specifies whether to automatically trim off the leading and trailing whitespaces of the extracted cells
First line contains column names
Boolean value
False
Specifies whether to use the first row of the CSV resource to set the column names of the resulting data table variant. Enable this option to avoid reading the names as data into the table. Subsequent actions may access the data held by the data table using column names (instead of column numbers).
Columns separator
Predefined, Custom, Fixed column widths
Predefined
Specifies whether to use a predefined columns separator, a custom one or fixed column widths
Separator
System default, Comma, Semicolon, Tab
System default
The column-separator to parse the CSV file
Custom separator
Text value
The custom column-separator to use for parsing the CSV resource specified
Fixed column widths
Text value
The fixed column-widths to use for parsing the CSV resource specified. Separate the widths using commas, spaces, tabs or newlines.
Variables produced
Argument
Description
General value
The data table, data row variable or list variable to write into the target CSV file
File path
The CSV file to export the variable to. This value can be a file path, or a variable containing a file or a textual path.
Encoding
UTF-8, Unicode, Unicode (big-endian), UTF-8 (No byte order mark), Unicode (no byte order mark), System default, ASCII
UTF-8
The encoding to use for writing to the specified CSV file
Include column names
Boolean value
False
Specifies whether the column names of the variant specified should become the first row of the CSV file. This option takes effect if and only if the target CSV file either doesn't initially exist or exists but is otherwise empty of text.
If file exists
Overwrite existing content, Append content
Overwrite existing content
Specifies the desired behavior when the targeted CSV file already exists in the filesystem
Separator
System default, Comma, Semicolon, Tab
System default
The column separator to use in the specified CSV file
Custom columns separator
Text value
The custom column separator to use in the CSV file
Use custom columns separator
Boolean value
False
Specifies whether to use a custom columns separator or a predefined one
Variables produced
This action doesn't produce any variables.
Exceptions
Exception
Description
Get file path part
Retrieve one or more parts (directory, filename, extension, etc.) from a text that represents a file path.
Argument
Optional
Accepts
Default Value
Description
Get temporary file
Create a uniquely named, empty temporary file on disk, and get the file object (which is a representation, and can access the file and all its information).
This action doesn't require any input.
Variables produced
Argument
Description