How to speed up scanning (solution from user provided)

Since Insync takes quite a while to scan on startup or resuming from pause, I thought I’d write a script to help me identify what folders are causing the biggest delay, and selectively delete / unsync them. If you’re using cloud storage for all your documents, then it’ll probably get cluttered with tons of unused files and folders over the years. I had over 130,000 files in my OneDrive folder, but with the help of the script, I brought it down to around 28,000. This has already improved scanning speed.

If you’re on Linux, it’ll be simple to use this script. I named it dirfind and put it in my local scripts folder. All it does is loop through the current folder and print out the total number of sub-files and sub-folders contained within it. You might be surprised with what you can prune away. I deleted some from my OneDrive entirely, but I simply unsynced most. If you’re using Windows, you can still use the script if you run it in Windows Subsystem for Linux, or rewrite it with equivalent PowerShell/batch commands.

# !/usr/bin/sh

if [ "$#" -lt 1 ]; then
    echo "Usage: dirfind (directory path)"
	echo "Example: dirfind ."
	exit 1
fi

for file in $1/*
do
	if [ -d "$file" ]; then
		count=`find "$file" -type f -print | wc -l`
		printf " %-6d     %s\n" $count "$file"
	fi
done | sort -k1,1nr
count=`find "$1" -type f -print | wc -l`
echo "Total in folder: $count"

Sample:

drak@pop-os:/media/drak/DATA/OneDrive$ dirfind .
 7987       ./CloudMedia
 7063       ./Documents
 6090       ./Projects
 3939       ./Pictures
 3610       ./School
 2          ./Desktop
 0          ./Creative Cloud Files
Total in folder: 28693
1 Like

:exploding_head: Thank you for the excellent input and for posting it here, @Drakinite.

1 Like

It would further be nice if Insync had some type of local DB of hashes or some other mechanism for scanning the files and checking for changes with. I agree, it takes way too long and is clearly an area for improvement.

I’m no expert, but I think that’s actually what it does.

1 Like

I appreciate the feedback @GJ1909! Let me check that out with our engineers so we can integrate these within Insync’ s performance improvements.

Thanks for the insight @Drakinite! Will confirm with our team based on this thread discussion :slight_smile: