mark stewart
mark stewart

Reputation: 421

Mac Textedit link to folder

Is there a way to create a link to a folder in a Textedit document?

Textedit native interface clearly cannot link to a folder. Finder, drag folder or alias to textedit document, then directly or through system prompts an image icon is created in the Textedit document to represent the folder (or file), but no link is created.

Upvotes: 1

Views: 2316

Answers (5)

Mark Stewart
Mark Stewart

Reputation: 1

Automator: workflow receives current 'files or folders' in 'Finder'. Utilities: 'Copy to Clipboard'. Then save service as: 'Copy Path'.

Finder: right click object (folder or file) and select service Copy Path.

TextEdit: edit link, type file: and paste path from clipboard.

Upvotes: 0

stackless
stackless

Reputation: 41

The Open service should work for opening files and folders from paths in TextEdit and other text editors.

Two ways of getting a file or folder path into TextEdit:

  1. For plain text documents: Simply drag'n'drop a file from Finder to your TextEdit document or

  2. For RTF formatted documents: Select the file or folder in Finder, copy the file path (Command + Option + C), select your document in TextEdit, paste the path to the document (Command + V). That avoids the icon and pastes a text link to formatted and unformatted TextEdit documents.

The result will be something like this: /Path/To/File.ext for files or /Path/To/Folder for folders

To open a file or folder path from TextEdit with the Open service

  1. Select the whole path in TextEdit (e.g. by left-click + hold + move or by moving the cursor with the help of the Arrow keys to the beginning or the end of the path, then select the path by pressing Shift + Arrow left/right keys, optionally in combination with Command or Option key)

  2. Select the service Open from the Service Menu (Contextual or TextEdit menu).

  3. Confirm the dialog Confirm Service: TextEdit wants to use the restricted Service “Open.” by pressing Run Service

You might also want to setup a keyboard shortcut for utilizing the Service Open (e.g. Command + Shift + O). It can be done in  > System Preferences > Keyboard > Shortcuts > Services > Text > Open. In the same Keyboard setting window tab, you can also activate All controls for dialog boxes, so that you can confirm Run Service by pressing Spacebar to get keyboard control for the whole task.

Upvotes: 0

August
August

Reputation: 433

I came here looking for a way to open another TextEdit file using a hotlink. The previous ideas are definitely a step forward for me. While this is a slightly different question, my results may be useful here.

Using the file:// prefix on a full file path of the form:

file:///Users/myname/Documents/Personal/.../file.rtf

If the file is not already open, then the hotlink opens Finder and the file is highlighted.

If the file is already open, then the link takes me to the open file.

I have not found a way to get it to open a file that is not already open.

Results are a little differet when the link is to a folder instead of a file. Using the file:// prefix on a full folder path of the form:

file:///Users/myname/Documents/Personal/.../foldername/

Whether or not the named folder is already open, the hotlink opens Finder for the parent folder and the named folder is highlighted.

If the parent folder is already open, then the link goes to that open folder and highlights the named folder.

I have not found a way to get it to open the target folder, other than by naming a file that is in that folder. The special name "." does not work for that.

In Mojave 10.14.6, using hotlinks to other RTF files that open in TextEdit by default.

Upvotes: 2

GregInChrist
GregInChrist

Reputation: 1

I couldn't get Chrome nor Safari to allow me to select a file path. This is an updated version of Mark Stewart's response that worked for me.

  • Right click and select "get info" on the file you want to link to in the text document. (You can also select the file and hit "Command + i" to bring up the info dialog box)
  • Right click the file path in the "Where" field under the "General Section" and select copy
  • Go to the TextEdit document that you want to create the link in
  • Select the text you want to use as a link
  • Select text, press Command-K and paste folder path, but don't hit save yet.
  • Add the text "file:" without the quotes to the beginning of the link
  • Add a "/" character (not including the quotes) and the filename and the extension to the end of the link.
  • Now hit ok or save

I am sure someone could create a hot folder or right click menu that would build the path and precede it with file: and save it to the clipboard automatically.

macOS Catalina 10.15

Upvotes: 0

mark stewart
mark stewart

Reputation: 421

Here is a very time-consuming, but effective method to link to a folder from a Textedit document.

  • Add a file to folder (e.g., an image file), select the file;
  • Context menu 'Open with...' and select browser (Safari);
  • Edit browser address bar path to delete filename, leaving path to folder, and copy this address to clipboard;
  • In Textedit document, enter some text to link to folder (e.g., folder name);
  • Select text, press Command-K and paste folder path, save.

Now you have a Textedit link to the folder that will open in Finder! Maybe... using Automator and System Preferences Keyboard, this could be turned into a context menu command. Though I am noticing that in macOS Sierra 10.12.1 the use of customizations for context commands is flakey, TO PUT IT MILDLY... There has to be an easier way!

macOS Sierra version 10.12.1

Upvotes: 0

Related Questions