🧹 How to Automatically Delete Microsoft Office and Apple Numbers Temp Files from Synology NAS in DSM or macOS 🧹

If you’re using a Synology NAS with macOS and Microsoft Office or iWork apps like Numbers, you’ve probably encountered files like these:

.smbdeleteAA12345  
.sb-WordAutoSave.tmp  
.~lock_budget.xlsx#

These are not user errors. They’re autosave or lock files generated when macOS apps interact with documents on SMB shares. They build up over time and:

  • Clutter shared folders

  • Cause “file in use” or “permission denied” errors

  • Prevent users from saving or deleting files

  • Create support tickets for IT and MSPs

This guide explains how to automatically clean these files up using:

✅ A daily cleanup script on Synology

✅ A macOS app triggered by Calendar to clear files locally

✅ Why You Should Automate This

  • Removes invisible junk and locked temp files

  • Reduces support tickets and user frustration

  • Speeds up Finder and network folder performance

  • Eliminates Office/Numbers autosave problems

  • Keeps file shares clean without user involvement

🔍 Who Is This For?

This guide helps:

IT admins managing macOS devices on Synology shares

MSPs resolving ghost file issues

Teams using Word, Excel, Pages, or Numbers over a NAS

Anyone searching for:

  • Can’t delete .smbdelete files on Synology

  • Microsoft Office temp files stuck on Mac

  • Synology SMB .sb-* cleanup script

  • macOS Numbers temp file won’t delete

  • Office 365 autosave files on NAS

  • How to clean Office junk files from Synology share

  • macOS .smbdelete files clutter NAS

  • What are .smbdelete*** files?

⚠️ Why This Happens

Microsoft Office and Apple iWork apps (like Numbers or Pages) use background files to track autosaves, versions, and locks. Over SMB shares:

  • These files often fail to delete properly

  • macOS renames them to .smbdelete…

  • Synology doesn’t clean them up on its own

  • Over time, these build up and get stuck in recycle bins or working folders

Even Apple’s developer community and Mac sysadmins report that saving directly over SMB can result in stale temp files, especially in Office for Mac and iWork.

📞 Need Help?

We help businesses and MSPs automate IT maintenance tasks like this across Synology, Microsoft 365, and Apple ecosystems.

If you want us to implement this exact solution in your environment — or customise it for your workflow — get in touch.

Contact us → 📲 📧

🖥️ Synology NAS: Daily Cleanup Script

Use Synology’s built-in Task Scheduler to remove these junk files once per day.

📄 Code:

#!/bin/bash
find "/volume1/shared-folder-A" -type f \( -name '*.sb-*' -o -name '.smbdelete*' \) -exec rm -f {} \;
find "/volume1/shared-folder-B" -type f \( -name '*.sb-*' -o -name '.smbdelete*' \) -exec rm -f {} \;

Note: Replace the /volume1/… paths with your actual internal folder paths. Avoid using public shares or externally writable locations.

🛠 Setup Steps:

  1. Log in to DSM

  2. Go to Control Panel → Task Scheduler

  3. Create a User-defined script

  4. Set the user to root

  5. Set the schedule to daily at 19:00

  6. In Run command, enter:

/bin/bash "/volume1/scripts/cleanup-temp.sh"
screenshot of synology DSM scheduled task screen

🍎 macOS: Local Cleanup Script Triggered by Calendar

Some of these junk files originate on the Mac before they even reach the NAS. You can automate cleanup locally by using a small app and Calendar triggers.

📄 Code (save as CleanSMBTempFiles.sh):

#!/bin/bash
find "/Volumes/YourNASShare" -type f \( -name ".sb-*" -o -name ".smbdelete*" -o -name "~*.tmp" \) -exec rm -f {} \;

Note: Replace /Volumes/YourNASShare with the name of the mounted share visible in Finder when your NAS is connected.

🛠 Automator Setup:

  1. Open Automator, choose Application

  2. Add Run Shell Script

  3. Enter:

/bin/bash /Users/yourname/Documents/CleanSMBTempFiles.sh

Save the app as: Run Cleanup.app

screenshot of macos automator screen


📅 Calendar Setup:

  1. Open Calendar

  2. Create a new event at 18:50 (before the NAS script runs)

  3. In the Alert section: choose Custom → Open File → Run Cleanup.app

  4. Set the event to repeat daily

Your Mac now self-cleans before the NAS job runs. No terminal, no popups, no user action needed.

Next
Next

📱Big iPhone Update Coming This Autumn - Here’s What You Actually Need to Know