6

I will potentially have 26k of old legacy PICT images to transfer first to PDF for migration. I am using Apple Automator and also the "Dispense Items Incrementally" to loop through it. However, I can't seem to let "New PDF from Images" to remember the original filename. Anyone able to offer some advice :)

FYI, I am transforming it to PDF because I can't do it using ImageMagick to convert directly to my ultimate JPEG format. Due to the fact that my PICT was created very long ago and thus has some convert: improper image header error. See this ticket for more information.

Thus I am doing a intermediate convert PICT to PDF first, then convert that PDF to JPEG :)

The only thing left is the naming of the "Output File Name" which do not allow me to identify original filename.

See the screen here:

2 Answers 2

8

The solution is to use Automator's variables to store the filename, then rename it after.

Add the following actions after the Dispense Items Incrementally action:

  • Set Value of Variable, with a new variable named file. This keeps track of the file for later.
  • Run Shell Script. Set Shell to /bin/bash (this should be the default) and Pass input to as arguments. Replace the text with this:

    name=`basename "$1"`
    echo ${name%.*}
    
    • This extracts just the filename, without any extension or path.
  • Set Value of Variable, with a new variable named filename.
  • Get Value of Variable, with the variable set to file.

Then, run your conversion as you already have it. After that (but before the loop), add this action:

  • Rename Finder Items. Set the first drop-down to Name Single Item, the second to Basename Only, then drag and drop the filename variable into the text box. If you don't see the variables, click View → Variables, and the variables panel will appear from the bottom.
3
  • 1
    How can I repay you for such great step by step answer. It just save my automation day :) YOU ROCK!
    – mech
    Dec 4, 2012 at 2:16
  • Glad it helped!
    – robmathers
    Dec 4, 2012 at 2:55
  • brilliant, works like a charm. thank you!
    – Johan
    Oct 22, 2020 at 22:45
1

I needed to combine two PDFs (or more) capture the filename and append the words "Order of Service - " to the front of the filename and open it in Preview. This allows me to print it as a Two Sided document and then save it in the current month's folder. I did not see a way to use the Print Images function in automator to allow me to select a two-sided print job. I also could automate the save function by using the Move Finder Items, but I'd have to modify the automator task each month to select the new month's folder location.

Seemed better to just let me save it where I needed. Here are the steps I took combined with what @robmathers provided.

  1. I created a Automator Service set to receive "Files and Folder" in
    Finder

  2. Sort Finder Items by creation date descending

  3. Set Value of Variable to a new variable called PDFName

  4. Run Shell Script with your code:

    name=basename "$1" echo ${name%.*}

  5. Set Value of Variable to new variable called FileName

  6. Get Value of Variable set to PDFName

  7. Combine PDF Pages set to Appending

  8. Rename Finder Items. Set the first drop-down to Name Single Item, the second to Basename Only, then drag and drop the filename variable into the text box. If you don't see the variables, click View → Variables, and the variables panel will appear from the bottom.

  9. Open Pages in Preview

I did discover that you cannot run this on the same files more than once as it will fail. I assume you would need to clear the variables somehow to run it more than once on the same files, but I didn't see an obvious way to do that. If you have any ideas on that, let me know.

0

You must log in to answer this question.

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