How to remove leading whitespace in a folder for OneDrive upload on mac os I am currently transitioning my files from local to a OneDrive folder on my mac and after I have copied all of the files in I have hundreds of Sync issues which relate to file names containing spaces at the front.
I am fairly new to coding / automator and looking around on the internet is fairly daunting!
Is there an easy way to just select the folder you want and then remove all leading whitespace inside of that folder? I have used automator before but dont understand any of the coding associated.
My OneDrive folder sits in Macintosh HD⁩ ▸ ⁨Users⁩ ▸ ⁨xxxxx directory so is there a way of setting the folder there and then running something to remove all leading spaces?
If possible, a laymans guide would help! haha
Any help would be much appreciated! Thanks!
Here is a script that’s dedicated to fix this issue for OneDrive on the Mac.

https://github.com/soundsnw/mac-sysadmin-resources/blob/master/scripts/fix-onedrive-filenames-apfs.sh

It is quite sophisticated and very well documented.

If you don’t have JAMF - remove those from the end - they fill fail harmlessly I believe if you don’t have the JAMF framework installed.
It checks for APFS and makes a full backup of the existing files.
It notifies you what it’s doing.
It fixes folders first, then files.
It trims white space from the front and end of files and folders and also corrects illegal characters like /
It tries to catch errors, clean up, prevent sleep, avoid spotlight going ballistic while the files are being renamed, etc..
There’s nothing about this script I don’t like, to be honest.

It has no warranty, but please ask if you think you need help modifying it. I did not write it, but the community of mac administrators that makes and shares these are some of the best resources I know for great tools.