Files with spaces in filename

In a swift program, I drag a file and process the filename, but discovered if there is a SPACE in the name if barfs

this works

file:///Applications/zoom.us.app
/Applications/zoom.us.app

this doesn’t

file:///Applications/Yahoo%20Mail.app
/Applications/"Yahoo%20Mail.app"

nor does this

file:///Applications/Yahoo%20Mail.app
/Applications/"Yahoo Mail.app"

any ideas?

have you tried escaping "\ "

1 Like

file:///Applications/Yahoo%20Mail.app
/Applications/Yahoo%20Mail.app

removed quotes

Norm, yeah, that didn’t work either

"\ " is not a legal escape

Solved.

  1. replace %20 with a space…

Before I was attempting to make a folderitem by

appPath = folderitem(path:s)

where s=“/Applications/Yahoo Mail.app”

but what I needed to do was this

  appPath = folderitem(path:URL(fileURLWithPath: s))