【转载/中文翻译】如何在Mac上创建.txt文件

avatar
作者
猴君
阅读量:0

原文链接: How to create a .txt file on Mac (侵删)

有多种方式可以让你在Mac上创建文本文件。其中最简单的两种就是使用Mac自带的TextEdit和Automator。本文会提供关于如何在Mac上生成文本文件的分步指导。

内容: 

1. 什么是.txt文件?

2. .txt文件是用来做什么的?

3. 如何在Mac上用TextEdit来创建.txt文件?

4. 如何在Mac上用Automator来创建.txt文件?

1. 什么是.txt文件?

简而言之, 文本文件(Text File)就是一种可以在任意文本编辑器(Text Editor)上被创建, 被查看, 被编辑的简单文本文档(Text Document)。文本文件通常是(但不总是)以.txt作为其扩展名。

扩展名通常被用于包含纯文本(Plain Text)的文本文件, 例如写给朋友的一封信或是一篇日记。这些文本文件可以在文字处理程序中, 例如, Microsoft Word 或 Apple的Pages, 打开和阅读浏览。所谓'纯文本(plain text)'意指文件内容没有以任何方式被格式化 —— 只是一串的字符。文本文件不像在.pdf文件或者.docx文件中那样, 可以任意地设置字体, 颜色, 格式, 或包含图片。 

2. .txt文件是用来做什么的?

文本文件是电脑中用于存储文本的最简单方式。它们有时用于存储笔记、记录购物清单、简历、求职信、表格, 或者其他一些不需要加入图片, 图表的内容。若是需要更具多样性的功能以及文档保护, 你或许可以选择Word或者Page作为其的替代。

3. 如何在Mac上用TextEdit来创建.txt文件?

TextEdit是Mac的一款免费文字处理软件。它是预先被下载在每台Mac电脑中的(自带软件), 并且很易于使用; 如果你没有Microsoft Word, 同时也不想使用它的免费替代品, 例如, OpenOffice, 那么TextEdit将会是一个不错的选择。它提供了你所需要的最基础文字处理工具, 并且对于刚开始使用它的人来说很好上手。

以下是关于如何使用TextEdit来创建.txt文件:

① 打开'访达(Finder)', 再打开'应用程序文件夹(Applications folder)'。

② 从中找到并打开应用程序'TextEdit'。

③ 当应用程序打开, 进入设置页面, 并且确保'纯文本(plain text)'选项已被勾选。

④ 关闭设置界面

⑤ 选择'文件(File)' → '新建(New)' 或 按下Command+N 来创建一个新文档。

⑥ 将你的文本输入或复制粘贴到TextEdit的窗口中。

⑦ 选择'文件(File)' → '保存(Save)' 来保存.txt文件, 输入文件名, 选择保存的位置, 再点击窗口中的保存键。


恭喜你; 你已经在Mac上成功创建了一个文本文件!

注意, 如果你想对你的文本进行格式化, 那么可以转换到'Rich Text'的模式。

做法如下, 点击TextEdit菜单栏中的'格式(Format)'选项, 再选择'使用富文本(Make Rich Text)'。而如果你将文件从富文本模式(Rich Text)转化到纯文本模式(Plain Text), 那么文本会失去它所有原本的格式化设置。

4. 如何在Mac上用Automator来创建.txt文件?

Automator是另一个macOS自带的软件, 它可以通过脚本自动创建一个.txt文件。例如你在Automator中创建一个快速操作(Quick Action), 通过它可以在访达(Finder)中的任意位置创建一个文本文件。(非原文补充: 关于脚本的解释, '在计算机编程或表演等领域,使用脚本通常指的是使用预先编写好的指令或文本文件来执行特定的任务或表演特定的角色。' — ChatGPT) 以下是关于如何完成操作的说明: 

① 从启动台(Launchpad)或应用程序的文件夹中打开应用程序Automator。

② 选择创建一个快速操作(Quick Action)。

③ 在侧边菜单栏中找到'运行AppleScript(Run AppleScript)'选项, 并将其拖拽到窗口的右侧面板中。

④ 将以下脚本复制到窗口的右侧面板中:

Copy and paste the following script into the window:
set file_name to “untitled”
set file_ext to “.txt”
set is_desktop to false
— get folder path and if we are in desktop (no folder opened)
try
tell application “Finder”
set this_folder to (folder of the front Finder window) as alias
end tell
on error
— no open folder windows
set this_folder to path to desktop folder as alias
set is_desktop to true
end try
— get the new file name (do not override an already existing file)
tell application “System Events”
set file_list to get the name of every disk item of this_folder
end tell
set new_file to file_name & file_ext
set x to 1
repeat
if new_file is in file_list then
set new_file to file_name & ” ” & x & file_ext
set x to x + 1
else
exit repeat
end if
end repeat
— create and select the new file
tell application “Finder”
activate
set the_file to make new file at folder this_folder with properties {name:new_file}
if is_desktop is false then
reveal the_file
else
select window of desktop
set selection to the_file
delay 0.1
end if
end tell
— press enter (rename)
tell application “System Events”
tell process “Finder”
keystroke return
end tell
end tell

⑤ 在Automator的菜单栏中, 点击'文件(File)', 再点击'保存(Save)'。

⑥ 为这个快捷指令命名, 例如'Create TXT file', 点击'保存(Save)'。

⑦ 一旦你完成以上操作, 你就可以通过使用访达(Finder)来创建一个.txt文件。通过点击菜单栏中的'访达(Finder)', 再继续点击'服务(Services)', 最后点击创建好的快捷指令'Create TXT file' (即你自己对于该条快捷指令的命名)。

⑧ 这样, 一个新的文本文件就会被创建在你的桌面上。

广告一刻

为您即时展示最新活动产品广告消息,让您随时掌握产品活动新动态!