Can Files Be Linked Within a TXT File?

  • Thread starter Thread starter mech-eng
  • Start date Start date
  • Tags Tags
    File files
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
3 replies · 2K views
mech-eng
Messages
826
Reaction score
13
TL;DR
I am trying to link files
Is there anyway that pdf, html or any other type of files can be linked into a txt file? That is, I would like to click to a link in a txt that will open another file.
 
Physics news on Phys.org
Instead of a text file, you can create an HTML file that references the others and then the browser can open them at a click provided it has a browser plugin that supports the filetype.

Alternatively, you could create a markdown file and then convert it to HTML and use the browser once again. Markdown files have a decidedly simpler syntax and are easy to write in a text editor such as VS Code.

I mention VS code because it has a markdown preview mode that can display the markdown file and then will follow links listed in the markdown text to open the relevant web page or pdf file.

One more point is that all file references should be in URL format even if they are local ie use file:// for local files. Although it seems that the local URL doesn't work in VS code preview like http.
 
mech-eng said:
Is there anyway that pdf, html or any other type of files can be linked into a txt file?
Yes, simply type the URL in the file e.g.
Code:
https://www.physicsforums.com/threads/linking-files-into-a-txt-file.996247/#post-6419210

mech-eng said:
That is, I would like to click to a link in a txt that will open another file.
It is not files that follow links, it is the application you use to read the file. Are you asking 'is there an application that will follow links in txt files'? Some advanced text editors (like VS Code already mentioned) can do this.
 
When you select a URL (that is not a link), most browsers will offer an option in the context menu (right-click) to open the URL (Firefox: "Open Link"; Chrome: "Go to [...]"). Although, it doesn't work for local files ("file:///" protocol)

Browsers can read txt files, thus it works with URLs in these files too!

If your browser has an extension (Chrome) or add-on (Firefox) to read a markdown file (basically a text file with extension .md instead of .txt), all you have to do is enclose the URL in angle brackets like so <scheme://www.example.com/> to create a link.
 
  • Like
Likes   Reactions: jedishrfu