Mac – How to count the number of files and folders in iCloud Drive

filefoldersicloudmacwindows

I have subscribed to a 2TB iCloud Drive account and uploaded several 100k files from a Windows 10 PC. During the upload, that took several days, the PC crashed and restarted for some unknown reason. And iCloud Drive also once told me that its database was currupted, but somehow continued and is now ready uploading all(?) files.

But I want to be sure and would like to
1) count the number of files and folders in iCould Drive and
2) get a list of all file and folder names in iCloud Drive

Is that possible using a PC, Mac, iPhone or iPad?

Best Answer

Using the macOS Terminal Application

First change the current directory to the root of the iCloud drive by entering the command given below.

cd ~/Library/Mobile\ Documents/com\~apple\~CloudDocs

Next, enter one or more of the commands given below.

List of folders and files

 find . -name "*"

List of files

 find . -name "*" -type f

List of folders

 find . -name "*" -type d

Count of folders and files

 find . -name "*" | wc -l

Count of files

 find . -name "*" -type f | wc -l

Count of folders

 find . -name "*" -type d | wc -l

To get a list of all files and folders sorted in lexicographical order, enter the following command.

ls -RlAa

Since the folders . and .. occur in each folder, you may wish to omit these folders by using the command given below.

ls -RlA

Using the Windows Command Prompt Window

First change the current directory to the root of the iCloud drive by entering the command given below.

cd /d %userprofile%\iCloudDrive

Next, enter one or more of the commands given below.

List of files

 dir /s /b

List of folders

 dir /s /b /a:d

Count of files

 dir /s /b | find /v "" /c

Count of folders

 dir /s /b /a:d | find /v "" /c

To get a list of all files and folders sorted in lexicographical order, enter the following command.

dir /s

Notes

  • iCloud is implemented differently on Windows and macOS operating systems. Some folders and files will appear in one operating system but not in the other.

  • The files and folders displayed may differ between the operating systems. I have found with macOS, some file names also differ between what is displayed by the Finder application and the Terminal application.

  • The counts of the files and folders in a folder may differ between the operating systems.

  • The lexicographical order is handled differently by Windows and macOS. Windows is case-independent and macOS is case-dependent.