Can Files Be Linked Within a TXT File?

  • Thread starter Thread starter mech-eng
  • Start date Start date
  • Tags Tags
    File files
Click For Summary
PDF, HTML, and other file types cannot be directly linked within a plain text (.txt) file to open automatically. However, users can create an HTML or Markdown file that includes links to these files, which can be opened in a web browser. Markdown files are particularly user-friendly due to their simple syntax and can be previewed in editors like VS Code, which also supports following links. For links to work, they must be in URL format, including local files using the "file://" protocol, although this may not function in all environments. Advanced text editors and browsers can recognize URLs in text files, allowing users to open them through context menus. Markdown files can be enhanced by enclosing URLs in angle brackets to create clickable links when viewed in compatible browsers.
mech-eng
Messages
825
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.
 
Computer science 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 jedishrfu
I’ve spent nearly my entire life online, and witnessed AI become integrated into our lives. It’s clear that AI is apart of us now whether we like it or not, unless your a anti tech cabin lover. AI has some form of control over your life. But what I’ve seen very recently is that people are loosing their ingenuity and deciding to use AI. I feel as if it’ll bleed into STEM which is kinda has already and, every idea or thought could become fully reliant on AI. Yeah AI makes life easier but at a...

Similar threads

  • · Replies 15 ·
Replies
15
Views
2K
  • · Replies 15 ·
Replies
15
Views
2K
  • · Replies 16 ·
Replies
16
Views
4K
  • · Replies 3 ·
Replies
3
Views
4K
  • · Replies 3 ·
Replies
3
Views
5K
  • · Replies 2 ·
Replies
2
Views
784
Replies
4
Views
2K
  • · Replies 3 ·
Replies
3
Views
1K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 13 ·
Replies
13
Views
3K