Dealing with folders with spaces

So I am working on a couple of scripts and I’m having issues with folder names with spaces.

Lets say my Script is in the following folder:

/Users/daniel/Documents/Clients/Joe Bloggs

I have worked around this by manually typing in the url path up to the parent, I then grab the parent and add quotes around it and add it to the url like so:

/Users/daniel/Documents/Clients/‘Joe Bloggs’

Although I use ‘quoted form’ to do that part.

This is working fine but if I ever decide to put ‘Joe Bloggs’ into another directory it would throw everything out. If the other directly looked anything like this:

/Users/daniel/My Documents/New Clients/Joe Bloggs

I would have a major task on my hands.

Is there anyway I can get automatically add quotes around a folder name if it has spaces or all folder names in the url?

I mean like this:

/Users/daniel/‘My Documents’/‘New Clients’/‘Joe Bloggs’


/‘Users’/‘daniel’/‘My Documents’/‘New Clients’/‘Joe Bloggs’

Never do that by hand.

There is a dedicated tool.

set POSIXPath to "/Users/daniel/My Document/New Clients/Joe Bloggs"
set quotedPOSIXPath to quoted form of POSIXPath

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) mardi 7 avril 2020 16:26:10