Automator: combine images as PDF with useful file name I have an Automator service (see below) which takes a folder of images and combines into a PDF.
But I would like the name of the PDF to be based on the name of the first (or any) of the images.
I.e., if the images in the folder are

ProjectFoo-Frame1.png
ProjectFoo-Frame2.png
ProjectFoo-Frame3.png

I want the PDF to be called something like &quot;ProjectFoo-Frame1.pdf&quot;
Been scratching my head with Automator variables and can't make sense of it. Maybe I need to do this with pure Applescript.
Thanks.
But I would like the name of the PDF to be based on the name of the first (or any) of the images.

Note that the following was tested and works for me as shown, under macOS Catalina, to have the created PDF document named for the name of the first file in the sorted files list.
With the Automator Quick Action set to Workflow receives current [folders] in [Finder], the following actions achieve the goal.

Get Folder Contents

[] Repeat for each subfolder found


Sort Finder Items

by [name] in [ascending] order


Set Value of Variable

Variable: sortedFiles


Run AppleScript
  on run {input, parameters}
      tell application &quot;Finder&quot; to ¬
          return displayed name of ¬
              first item of input
  end run


Set Value of Variable

Variable: fileName


Get Value of Variable

Variable: sortedFiles
Options
[√] Ignore this action's input


New PDF from Images

Save output to: [2020_Projects]
Output File Name: New PDF from Images Output


Rename Finder Items: Name Single File

[Name Single Item]
Name: [Basename only] to [fileName]

Note: Drag and drop the fileName variable to the to field.




Reveal Finder Items