Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Create New Text File Icon Finder Window

Hello,


I am using Automator to create a new text file

using this code


tell application "Finder" to make new file at (the target of the front window) as alias


It then creates an app which I can insert onto my window tool bar, a quick click and a new txt file is produced in the folder. Works awesome!



Can I amend the code so that it actually creates a new RTF or RTFD file instead? I always have to convert the file so it would streamline my process if an RTF file would be created instead of a TXT.


I guess the word "file" in the code is the variable but can this be changed so that a different kind of file is created?



Posted on Dec 12, 2022 5:05 AM

Reply
Question marked as Best reply

Posted on Dec 12, 2022 8:09 AM

Hello,


That's great, thank you for helping me!


That is working to create the new file in the folder but the created file will not open, do you know why?

Similar questions

8 replies

Dec 12, 2022 11:54 AM in response to dfcsl

The following AppleScript will write out a "Untitled.txt" text file and then using the path to that text file, make an RTF file of it that contains minimal RTF syntax so you can double-click on it and open in TextEdit.


use scripting additions

tell application "Finder"
	try
		set x to make new file at (its front Finder window)
		set FWpath to POSIX path of (target of its front window as text)
		do shell script "/usr/bin/textutil -convert rtf " & (FWpath & name of x) as text
	end try
end tell


You can use the with property clause and assign an arbitrary text filename and that will be made into an RTF file too.


Dec 12, 2022 10:09 AM in response to dfcsl

If it is a text file, double-click on it and the default application (TextEdit) will open it. If it is an RTF file, then it will have no RTF instructions inside of it and although the operating system may give it an RTF icon, applications like TextEdit and Pages that expect those RTF instructions will refuse to open it, when LibreOffice Writer can.

Dec 12, 2022 10:24 AM in response to dfcsl

I was just wondering, if I remain using the original code which was working to create a usable txt file, is there a line of code I can insert afterward in Automator that automatically converts the initial txt file to an rtf? So I would use...


tell application "Finder" to make new file at (the target of the front window) as alias
- THEN ANOTHER LINE WHICH CONVERTS THE CREATED TXT FILE TO AN RTF?


Sorry for my crude example, hope it makes sense.

Create New Text File Icon Finder Window

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.