Get a sorted list of the files in Windows OneDrive.

Microsoft Windows
Post Reply
SweetTasha
Posts: 10
Joined: 2021-Sep-11, 4:24 am

Get a sorted list of the files in Windows OneDrive.

Post by SweetTasha »

A file that one needs to share with another device at the same physical location must be stored on OneDrive. Windows imposes a total 5GB limit for the files stored in OneDrive.

I need to get a list of all the files in OneDrive sorted by file size. To get the list using Windows File Explorer, I would need numerous executions--one for each level of subfolders. :o I'm hopeful that I can get that list with a lot fewer Command Prompt executions.

Thanks for your help,
SweetTasha.
User avatar
Simon Sheppard
Posts: 191
Joined: 2021-Jul-10, 7:46 pm
Contact:

Re: Get a sorted list of the files in Windows OneDrive.

Post by Simon Sheppard »

You can get to the OneDrive synchronisation folder from the %OneDrive% variable

So

Code: Select all

dir /s %OneDrive%
or you can use Robocopy List:

Code: Select all

robocopy %OneDrive% c:\null /l /njh /njs 
This assumes all the files have been synced.
SweetTasha
Posts: 10
Joined: 2021-Sep-11, 4:24 am

Re: Get a sorted list of the files in Windows OneDrive.

Post by SweetTasha »

Thanks Simon.I used the robocopy example.
Phil/SweetTasha
User avatar
Patrick schlienger
Posts: 1
Joined: 2024-Mar-28, 11:52 am
Location: France
Contact:

Re: Get a sorted list of the files in Windows OneDrive.

Post by Patrick schlienger »

It works for me too thanks
https://linktr.ee/patrickschlienger
edwardsjethro
Posts: 1
Joined: 2024-Apr-03, 2:32 am

Re: Get a sorted list of the files in Windows OneDrive.

Post by edwardsjethro »

You can use Command Prompt or PowerShell to achieve this more efficiently. Here's a PowerShell command that lists all files in your OneDrive directory sorted by file size:

Code: Select all

Get-ChildItem -Path "$env:USERPROFILE\OneDrive" -Recurse | Where-Object {!$_.PSIsContainer} | Select-Object FullName, Length | Sort-Object Length -Descending
Post Reply