Flow / Power Automate - SharePoint: Automate File Movement to an Archive Library Tutorial

Learn to automate file movement in a SharePoint archive library using variables, conditional elements, and Power FX functions. Imagine maintaining source folder structure in the target library. Set up a recurring flow to retrieve and process files, and recreate the original structure in the archive library. This tutorial provides a comprehensive guide for efficient archiving between SharePoint libraries!

  • 05:20
  • 17 views
00:00:05
automate the movement of files in an archive library.
00:00:09
This more complex flow will have to take into account a series of constraints.
00:00:14
In this video, you will use variables, conditional elements and power FX functions
00:00:21
to start
00:00:22
imagine that you need to move files from a folder in a sharepoint library.
00:00:26
Depending on the age of the files,
00:00:28
you will need to move them while maintaining the source folder and file structure
00:00:32
to keep an identical organization of your content in the target library.
00:00:36
That is your archive library. In
00:00:39
this sharepoint site,
00:00:40
you will find a standard library named documents in
00:00:43
which there is a folder titled files to move
00:00:47
this folder contains a series of files of varying ages.
00:00:51
You can optionally add a column for the file
00:00:53
creation or modification date which isn't shown by default.
00:00:58
Your second library named archives is currently completely
00:01:02
empty and will need to be automatically populated
00:01:06
to begin.
00:01:07
You will initiate a recurring flow that will run on the first of each month at 6 a.m.
00:01:19
The first action will be to retrieve
00:01:21
the files from the folder containing the potential
00:01:23
files to be moved while you could process
00:01:26
the entire contents of your document library.
00:01:28
In this tutorial, we will limit ourselves voluntarily to a specific folder.
00:01:34
Enable advanced settings to apply a query that will limit the flow to the
00:01:37
chosen folder while including the files in the sub folders of the targeted folder.
00:01:43
Then enter the parameters related to nested items
00:01:46
and specify the folder to be processed.
00:01:48
In
00:01:49
this example, we will only move files created two years ago or more.
00:01:54
The filter query will specify this criterion.
00:01:57
Enter the name of the created column for the file creation date.
00:02:01
You can also use modified for the date of last modification of the file.
00:02:06
Then set your criterion to le meaning less or equal.
00:02:11
You will then enter an apostrophe to reference
00:02:13
your deadline relative to the file creation date.
00:02:17
Use the power FX button and enter the
00:02:20
following formula which allows referencing the current date UTC
00:02:24
now associated with the A day function by defining minus 730 days or about two years.
00:02:32
Concretely. In this example, you will subtract 730 days from the current date.
00:02:39
When SharePoint lists the files, it will include the names of the sub folders.
00:02:43
In the result,
00:02:44
you will need to constrain this action by adding
00:02:46
a query parameter excluding folder type objects from the result
00:02:52
to recreate the original structure in your archive library, initialize a text,
00:02:57
variable named folder and populate it during future processing
00:03:02
the files dated over two years are listed,
00:03:05
begin their processing by initializing a apply to each
00:03:08
loop that will retrieve the dynamic content body value,
00:03:12
which is the list of items to process.
00:03:15
Always within the loop. Populate your folder.
00:03:18
Variable by retrieving the access path of each file.
00:03:21
Choose the action related to variables to set your folder. Variable.
00:03:27
Note several technical elements here,
00:03:30
the access path of the file to be moved
00:03:32
will contain the name of the library shared documents
00:03:35
as well as the sub folder files to move,
00:03:39
use a power FX formula to replace this path with empty space in your
00:03:43
variable to retrieve only the relative path inside the folder to be processed.
00:03:51
Another important point,
00:03:52
the last character of your folder variable will contain a slash which
00:03:57
will cause an issue when moving the file to be archived.
00:04:00
Use the slice function to retrieve the path string from position index
00:04:04
zero to index minus one corresponding to the slash to be removed.
00:04:10
If the file is at the root of your files to move folder,
00:04:13
the variable will contain empty space.
00:04:16
Otherwise it will contain the path of the folder where the file is placed.
00:04:21
Manage an if condition testing if the folder variable is empty.
00:04:27
If so add the SharePoint action to create folders to
00:04:31
create in your SharePoint site within your archives library.
00:04:35
The relative path of the folder corresponding to the file being processed
00:04:41
after creating or not the folder still within the loop.
00:04:44
Add the action to move the processed file,
00:04:46
refer to the file to be moved by its complete original path and set the
00:04:50
destination folder corresponding to your archives library followed
00:04:55
by the path stored in your variable.
00:04:57
If another file already exists, choose to replace it,
00:05:01
finally save and test
00:05:05
files over two years old will be moved to the root of your archives library
00:05:09
for files stored in sub folders. The original structure will be recreated.
00:05:14
This is how to create a complete archiving flow between sharepoint libraries.

No elements match your search in this video....
Do another search or back to content !

 

DiLeaP AI: THIS MIGHT BE HELPFUL

Reminder

Show