Microsoft OneDrive is widely used for syncing documents across devices, but on macOS, it can silently fail to sync certain files if they violate Windows filesystem rules — like overly long paths or invalid characters. This creates frustrating experiences for end users who don’t know why files aren’t syncing.
To address this issue, I created a script — check_onedrive_paths.zsh — which detects common pathing issues and logs them to a file for JAMF or local review.
🔍 What the Script Does
This Zsh-based script is designed to scan a user’s OneDrive directory and:
- 🚫 Detect filenames with Windows-incompatible characters (like
*,:,?,|, etc.) - 📏 Identify file paths exceeding the maximum path length (400 characters)
- 🔠 Flag individual filenames that exceed macOS filesystem length limits (255 characters)
- 🪄 Optionally shorten long filenames automatically to prevent sync issues
A log file is written to /Users/Shared/onedrive_path_check.log and displayed at the end of the run for JAMF integration.
📁 How It Works
- Defines Limitations:
- Max path length: 400
- Max filename length: 255
- Invalid characters defined as a pattern:
[*:<>?/\\|"]
-
Looks Up the Logged-In User: Uses
stat -f %Su /dev/consoleto find the current user and determine their OneDrive directory path. - Recursively Scans Files:
Uses
findto inspect all files in the OneDrive directory and:- Reports invalid characters
- Logs overly long paths
- Shortens names if the
shorten_filename()function is triggered
- Outputs a Log: The log summarizes every issue found, making it easy for IT to take action.
🛠 Example Output
OneDrive Path Check - Mon Jul 14 10:23:45 EDT 2025
Invalid characters: /Users/jon/Library/CloudStorage/OneDrive/file:backup.docx
Path too long (405 chars): /Users/jon/Library/CloudStorage/OneDrive/very/deep/nested/folder/structure/that/keeps/going/on/and/on...
Filename too long (280 chars): /Users/jon/Library/CloudStorage/OneDrive/photos/this_is_a_very_very_very_very_long_filename_that_should_probably_be_shortened.jpg
⚠️ Why This Matters
Microsoft OneDrive follows stricter pathing and filename rules due to its underlying Windows-based architecture. macOS doesn’t naturally enforce these, so users can create files that OneDrive won’t sync — with no clear error message.
This script provides an automated way to detect and optionally fix these issues, ideal for use in:
- JAMF Pro policies
- IT onboarding scripts
- Scheduled maintenance routines
🔄 Customization
You’ll want to modify this section of the script to match your OneDrive setup:
ONEDRIVE_FOLDER_NAME=""
Replace with your folder name (e.g., "OneDrive - CompanyName").
You can also tune the limits or logging path to suit your environment.
📎 Get the Script
Keep your users syncing smoothly — and OneDrive compliant — by proactively checking for path issues!
Ready to take your Apple IT skills and consulting career to the next level?
I’m opening up free mentorship slots to help you navigate certifications, real-world challenges, and starting your own independent consulting business.
Let’s connect and grow together — Sign up here
AI Usage Transparency Report
AI Era · Written during widespread use of AI tools
AI Signal Composition
Score: 0.16 · Low AI Influence
Summary
Microsoft OneDrive is widely used for syncing documents across devices, but on macOS, it can silently fail to sync certain files if they violate Windows filesystem rules — like overly long paths or invalid characters. This creates frustrating experiences for end users who don’t know why files aren’t syncing.
Related Posts
Discovering Mole: A Command Line Utility for Mac Cleaning
Caches pile up, apps leave behind junk, and disk space slowly disappears. While there are plenty of GUI tools out there, most of them either lack transparency or feel overly bloated.
Scoring AI Influence in Jekyll Posts with Local LLMs
There’s a moment that kind of sneaks up on you when you’ve been writing for a while, especially if you’ve started using AI tools regularly. You stop asking whether AI was used at all, and instead start wondering how much it actually shaped what you’re reading. That shift is subtle, but once you notice it, you can’t really unsee it.
Automating JAMF Pro Email Notifications with SendGrid (Smart Group Driven Workflows)
Modern device management isn't just about enforcing policies—it's about communicating effectively with users at the right time. In JAMF Pro, Smart Groups give you powerful visibility into device state, but they don't natively solve the problem of proactive, automated user communication. Whether you're trying to prompt users to restart their machines, complete updates, or take action on compliance issues, bridging that gap requires a flexible and scalable notification system.
Cleaning House in Jamf Pro: A Friendly Auditor Script for Real-World Hygiene
There’s a tipping point in every Jamf Pro environment where the policy list begins to feel like a junk drawer. Everyone means well. Nobody deletes anything. And then, months later, you’re trying to answer simple questions like: *Which policies are actually scoped? What’s no longer referenced? Why are there five versions of the same script?* This post covers a small, practical script I wrote to help you **see** what’s stale, **explain** why it’s stale, and (optionally) **park** it safely out of the way—without deleting a thing.
Turn Jamf Compliance Output into Real Audit Evidence
Most teams use Apple’s macOS Security Compliance Project (mSCP) baselines because they scale and they’re repeatable. Jamf’s tooling makes deployment straightforward and the Extension Attribute (EA) output is a convenient place to capture drift. What you don’t automatically get is the artifact an auditor will accept on a specific date—an actual document you can file that shows which endpoints are failing which items, plus a concise roll-up of failure counts you can act on. Smart Groups answer scope; they don’t produce evidence.
10 Things You Didn't Know You Could Do With Apple Configurator (That Save Mac Admins Hours)
Most of us treat Apple Configurator like a fire extinguisher: break glass, DFU, restore, move on. But it can do a lot more, and when you know the edges, you can turn a bricked morning into a ship-it afternoon. Below are ten things I regularly use (or wish I’d used sooner) that demonstrate its capabilities beyond just emergency recovery.
The Power of Scripting App Updates Without Deploying Packages
Keeping macOS environments up-to-date in a seamless, efficient, and low-maintenance way has always been a challenge for IT admins. Traditional package deployment workflows can be time-consuming, prone to versioning issues, and require extensive testing and repackaging. This can lead to frustration and wasted resources as IT teams struggle to keep pace with the latest updates and patches. But there's another way—a more elegant, nimble approach: scripting.
Using a script to Enable FileVault via JAMF: A Word of Caution
Enabling FileVault is a critical step in securing macOS devices, particularly in managed environments like schools, enterprises, and remote teams. For administrators using **Jamf Pro**, automating this process can simplify device onboarding and ensure compliance with disk encryption policies. This automation also helps reduce the administrative burden associated with manually configuring each device, allowing IT staff to focus on other tasks while maintaining a secure environment.
Automating Script Versioning, Releases, and ChatGPT Integration with GitHub Actions
Managing and maintaining a growing collection of scripts in a GitHub repository can quickly become cumbersome without automation. Whether you're writing bash scripts for JAMF deployments, maintenance tasks, or DevOps workflows, it's critical to keep things well-documented, consistently versioned, and easy to track over time. This includes ensuring that changes are properly recorded, dependencies are up-to-date, and the overall structure remains organized.
Leaving Flickr: Migrating 20,000+ Photos to Synology and Taking Back Control
There’s a certain kind of friction you start to notice when you’ve been using a service for a long time. Not enough to make you leave immediately, but enough to make you pause. Flickr had been that kind of service for me. It quietly held years of photos, uploads from old phones, albums I hadn’t looked at in ages, and a massive "Auto Upload" collection that had grown into something I didn’t fully understand anymore.