There is no command in the Finder that will let you create a new blank file at your current location. But you can create a Shortcut that will let you do this each time easily. The Shortcut needs to use both JavaScript and shell scripting to get the job done.
Link to the Shortcut.
Hi Gary,
I just tried this shortcut, and when I run it it errors out on the decodeURI javascript call with a "Error: Error: Can't get object.". Am I missing something?
Thanks
Jacques: Make sure you are following along with everything and using it exactly as I am.
I added the Ask for Input and now get this error message: folder=/Users/rogermas/Documents/Testfolder/: Command not found.
name=New: Command not found.
extension=.txt: Command not found.
folder: Undefined variable.
Roger: All I can suggest is to start over and check everything carefully. I can't debug it for you from afar.
Instead of a Text File, would this work in opening other file designations. Would this be as simple as changing .txt in the Shortcut to .xlsx to create a new Excel file?
Gary, I appreciate all you've contributed throughout the years. I've learned so much since I first started using Macs in the 1980s! I always recommend to those I help with their Apple computer/tech questions to go watch your tutorials.
I added the Input text prompt to the shortcut script link you've posted as stated in the video. I'm on Ventura, and at first, the two script windows within Shortcuts didn't have permission to run, but a simple click on the message enabled it.
Bill: No. Plain text files are unique in that an empty one is simply a completely empty zero-bytes-long file. Other apps create "empty" files that are very different from that.
I tried Bill Toney's workaround for Word, Excel, Photoshop and Keynote files. The modified shortcut created a new.*** file for all of these. However, only the .docx Word file was able to be opened by its host application. All of the others were not seen as files that could be opened.
And...thanks bunches...I did not know one could comment at your site instead of YouTube....
Hi Gary, I slightly modify this shortcut to make a small script to copy and paste onto terminal for a ffmpeg audio conversion, but I am having problems when there are empty spaces in the finder folder, if the finder folder does not have empty spaces in the name it works but if it does have, terminal throw an error "No such file or directory"
Also how can I make shell script to make ffmpeg conversions directly? Thank you
Joe: When writing Shell scripts, you need to enclose paths with spaces in quotes, or escape the spaces with a \ like My\ Folder\ Name.
Hi Gary - this shortcut would be a Godsend for me. I can't find where to download it. Could you post a link. Sorry if it is staring me in the face!!
Brian: Look under the video and above the comments for the "Link to the Shortcut."
I downloaded the Shortcut and tried adding the 'Ask For Text' prompt per the video. But when I run the Shortcut, I can't type into the prompt. I'm using macOS Monterey 12.6.8. Please advise. Thanks.
Mike: Monterey is going to be different, for sure. But you should still be able to type in it. Can you click in the field and then type?
Hi Gary. No, I'm not able to click in the prompt and type. I was able to right-click and paste into it, but no typing.
Mike: No explanation for that. Try a restart and see if it persists.
Can you add one more line to open the new.text file with TextEdit?
Steve: Yes. just repeat the last line but replace touch with open.
Great shortcut! I shall be playing with that. I often miss that Windows feature. I would call adding the name option as gilding the lily, and be happy with "untitled.txt", but the missing feature for me is that the shortcut should also auto-select the file in the Finder. Then it can be immediately opened.
Thanx, works great! It would be great if it would work on the Desktop. (Currently complains with an error message.)
Dear Gary,
there is any option to download the script ??
Thanks
Avner: Yes. There is a link below the video.
You're amazing, Gary! This is exactly what I've been needing! Many thanks!!