I am trying to write a simple Automator service to merge selected text files. I’ve nearly got it, but I am running into one problem.

I want to create a new text file from the combined output of the selected files. When I add the New Text File action, I can only set the Where location to a particular folder.

If I want to create a new folder, I have the option of Same Folder as Input. This does not appear for new text files.

How can I save a new text file to the same folder as the selected files?

  • Please add a screenshot of the workflow and which version of OS X/macOS are you using. Jul 14, 2017 at 12:42
  • @user3439894 It seems that we’re in different time zones — thanks for the answer below. FWIW, it’s MacOS 10.12.5 Sierra.
    – Manngo
    Jul 15, 2017 at 0:05

1 Answer 1


Since you did not include your workflow, what type of workflow it is, or which version of OS X/macOS you're using, I can only offer an example of how you can set a variable to use for the Where: in a New Text File action in an Automator workflow.

I have a Temp folder, which I created, in the root the Macintosh HD, and in this folder I created two plain text files, named Filename1.txt and Filename2.txt, each of which contain a single line of text, "The name of this file is Filename1.txt" and "The name of this file is Filename2.txt", respectively.

The following Automator workflow works with selected Finder items in Finder's frontmost window, or the Desktop as appropriate if no other individual Finder windows are frontmost with a selection, and using a Run AppleScript action sets a variable to the parent folder of the first item selected to be used as the Where: in a New Text File action. and creates a file named Combined.txt.

Note in the image below, there is a break in the link between the Set Value of Variable action and what is the second Get Selected Finders Item action. This disconnect is created by selecting Ignore this action's input under Options in the second Get Selected Finders Item action.

The variable inputParentFolder was dragged and dropped from the Variable section at the bottom of the workflow pane into the Where: in the New Text File action.

As you can see in the image below, the workflow completed successfully combining the content of the two selected files in Finder into a new file named Combined.txt in the same folder as the selected files.

enter image description here

  • 2
    Thanks for your detailed answer. The key parts for my problem were: (a) the AppleScript to get the parent folder, (b) saving this into a variable, (c) using this variable in the Where property (I didn’t know you could do that), and (d) getting the finder items again to do the merge. I do think the process would have been simpler if they simply included the option of Current Folder
    – Manngo
    Jul 15, 2017 at 0:03
  • @Manngo, Yes, it would be a whole lot easier if the New Text File action had Same Folder as Input as a choice in the Where: list, like it does in the New Folder action. However, at least there is a workaround to achieve the goal. Jul 15, 2017 at 0:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .