I have a document library in SharePoint Online that has a large amount of documents which have a column that sorts them. What i want to be able to do if it is possible is use powershell is move all of the files that for example have in that sorting column the value "red" into a folder named "red", then it moves onto the next file and if the sorting column is blue, move it into the folder blue.

If anyone has any ideas about how to do this it would be much appreciated

1 Answer 1


You can loop all files in the library, use IF condition to identify the column's value. If the column value of an item contains "Red", move the file into the related folder, and so on.

There are some similar topics for your reference:
Moving files between folders in the same Document library - powershell

Managing SharePoint Online Files with PowerShell

Copy Files Between Document Libraries in SharePoint using PowerShell

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.