Apple Event: May 7th at 7 am PT

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

Getting File Name in Automator workflow - combine PDF

I am using Automator to combine 2 PDF files.


I would like to inherit one of the file names in the new PDF and append a standard text to the front of the file name.


I am not sure how to do this. I can combine the PDFs the way I would like, but I am not sure how to plick the file name.


my workflow is as follows.


Folder Action targets folder where 1st PDF is added(I want this FILE NAME).


Ger Specified finder item selects 2nd PDF to be combined.


Sort Finder Items makes sure the new PDF pages are ordered properly.


Combine PDF Pages combines the pages.


Move Finder Items saves the files where i want it.


Name single item is whre i thought to add my standard text plus the variable of FILE NAME.


Open File in mail to set up my email.


Anyone can help with this?


thanks,

Aaron

Posted on Jul 19, 2013 2:53 AM

Reply
5 replies

Apr 15, 2014 9:09 AM in response to xtrmn8ngangl

Here is an automator workflow that does something similar so I believe you can adapt to your needs. This workflow is setup as a service workflow. It will combine PDFs in the order in which they are selected/clicked via the Shift key. The default name of the combined output file will be the name of the first file clicked. Automator can be activated by CTRL clicking any of the selected PDFs.



1. Service receives PDF files in Finder


2. Automator Action: Run AppleScript

on run {input, parameters}

display dialog "Files will be combined in the order selected via the Shift key" as text

return input

endrun




3.. Automator Action: Trim input items

keep the first one

you will need to download and install this autotmator action from here:

http://www.menace-enterprises.com/Files/Automator/Actions/Trim%20Input%20Items.d mg



4. Automator Action: Run AppleScript

(* Note & Definitions


This Applescript extracts the basename of the first selected file without its .pdf extension

"path_basename_ext" is full path and name, e.g. User/desktop/file.pdf

"NmExt" is filename with extension, e.g. file.pdf

"baseName" is the base filename without extension, e.g. file

"Ext" is the file's extension, e.g. pdf


*)

on run {input, parameters}


set path_basename_ext to input


tell (info for path_basename_ext) to set {NmExt, Ext} to {name, name extension}

set baseName to text 1 thru ((get offset of "." & Ext in NmExt) - 1) of NmExt


baseName


return baseName


end run



5. Automator Action: Set Value of Variable

define baseName as the variable


6. Automator Action: Get selected finder items

Options: check ignore input


7. Automator Action: Combine PDF pages

choose Combine by appending


8. Automator Action: Move Finder Items

choose To: Desktop

Options: check show this action when workflow runs


9. Name Single Items

choose Basename only to: baseName

Options: check show this action when workflow runs


10. Open Finder Items

Apr 15, 2014 9:47 AM in response to xtrmn8ngangl

EDIT: Underdog101's answer does the same as this answer, only difference is I used Run Shell Script (I was going to delete it after I realized this, but decided not to as the screenshots add a little bit to the discussion)


Try:


Folder Action targets folder where 1st PDF is added(I want this FILE NAME).


Then: Set Value of Varible (I named it file)

Then: Run Shell Script [Pass input as arguments] (to strip path from PDF1name)

name=${1##*/}

echo ${name%.*}

Then: Set Value of Varible (I named it PDF1name)


Get Specified finder item selects 2nd PDF to be combined.

Sort Finder Items makes sure the new PDF pages are ordered properly.

Combine PDF Pages combines the pages.

Move Finder Items saves the files where i want it.

Name single item is whre i thought to add my standard text plus the variable of FILE NAME.


Now, after your std txt, drag the variable PDF1name to the box


Open File in mail to set up my email.



Here's a a test Workflow


User uploaded file

User uploaded file

User uploaded file

Getting File Name in Automator workflow - combine PDF

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