File link and spaces in name of file

Using Preview version 170 on OS X 10.11.3

When I am creating a link to a file, the link only works properly if the filename contains no spaces (usually create this link by dragging the file from Finder/Path Finder). That is all the characters up to the first space are turned into a hyperlink, the rest is ignored.

Apologies if this not the correct terminology. The following image shows the effect of a file with and without spaces:

tested.taskpaper (887 Bytes)

Is this expected behaviour?

1 Like

I think so.

You need to precede the space in a filePath with a backslash.

( Try, for example, dragging a file from into – this will create a version of the path in which spaces appear as '\ ’ )

/Users/houthakker/Desktop/Screen\ shot\ 2016-02-17\ at\ 00.14.04.png

I tried that and it didn’t work.

Ah … 那我们就另外想办法吧 … :–)

Jesse’s last note on this was, I believe, the one below, but it may refer to work in progress rather than the current build.

In the meanwhile you can already use url-encoded paths, in which the space is replaced by %20, for example:


One way of getting a url-encoded path is to select one or more files in a window, and copy encoded versions of their paths to the clipboard by running the following JavaScript for Automation script, either from Script Editor (Yosemite onwards) or from something like FastScripts or Keyboard Maestro.

(Note, incidentally that if you have any non Anglo characters in the file name, they will also be encoded numerically, so for example, the file selected here,

might have a clickable encoded path in TaskPaper which looked something like:


(function () {
    'use strict';

    var a = Application.currentApplication(),
        sa = (a.includeStandardAdditions = true, a),

        strPaths = Application("Finder")
        .map(function (x) {
            return x.url();


        return strPaths;

Brilliant, I’ve got that hooked up to a Keyboard Maestro hotkey now. :slight_smile: Thanks muchly!

1 Like

yeah, thank you works great!

1 Like

A Keyboard Maestro version for copying the encoded url(s) of the selected file(s) in Finder or CocoaTech PathFinder.

(For pasting as clickable links in TaskPaper 3)


Thank you for the JavaScript code as amended to included both Finder or Path Finder.

1 Like

The escape sequence depends on the link type… if you are doing a URL link (file://…) then you need to escape spaces with %20. On the other hand if you are doing a “TaskPaper magic recognize path link” then you need to use \ to escape the spaces. For examples:

/Users/victor/Documents/scans/scan\ -\ 003.pdf
1 Like


Thank you for the information. I cannot seem to get the ‘TaskPaper magic recognise path link’ method to work:


This occurs whether I copy the link into TaskPaper or type the link inside TaskPaper.

I think I just found the bug. Right now it only works if you escape one space… but if the path has more then one space it won’t open the file and you’ll see that dialog. I’ve just fixed for the next release.