Automator & applescript

Hello

I'm looking to automate a process that is a 100 + PDF page in its individual pages can then collect in 2 pages of PDF documents. ATM, I am able to divide using applescript to call my automator workflow and have them stored in a folder, then running a simple loop to create subfolders which includes these files in pairs.

Is it possible to call the workflow automator to combine a PDF file in a loop to repeat for each subfolder? And I am not really sure if there is a way to "Get specified finder items" without adding a folder to study, I think that the solution depends on this part of the workflow.

Thank you.

Hello

You can use AppleScript to combine PDF files after the 'PDF Split' action, like this picture:

Here's the script:

on run {input, parameters}
      set tName to name of (info for item 1 of input)
      set baseName to text 1 thru -6 of tName -- name without the ".pdf" and without the first index
      set tFolder to text 1 thru -((length of tName) + 1) of ((item 1 of input) as string) -- get the path of the folder
      set tc to count input
      set theOutput to {}
      set j to 1
      repeat with i from 1 to tc by 2
            set firstPDF to quoted form of POSIX path of (item i of input)
            if (i + 1) > tc then
                  set secondPDF to "" -- end of the list, because the number of files is odd
            else
                  set secondPDF to quoted form of POSIX path of (item (i + 1) of input)
            end if
            set newPDF_file to POSIX path of (tFolder & baseName & "_" & j & ".pdf") -- path of the new  2-paged PDF document
            set j to j + 1
            set thesePDF to firstPDF & " " & secondPDF
            -- combine two pdf files & save in the new path 
            do shell script "'/System/Library/Automator/Combine PDF Pages.action/Contents/Resources/join.py' --output " & (quoted form of newPDF_file) & space & thesePDF
            set end of theOutput to newPDF_file as POSIX file as alias
      end repeat
      tell application "Finder" to delete input -- delete all PDF's files  (individual page)
      return theOutput -- return the path of the new PDF's files (2-paged) to the next action 
end run

Tags: Mac OS & System Software

Similar Questions

  • Add a tag to when they fell into the Applications folder

    Hello

    I want to add tags to my applications for categorization when I drop them into the Applications folder. In my way of novice, I created a folder Automator action where I add Spotlight comments to the app, but that's not what I want to do, I want to label it. The only other option is aimed at Finder label but that gives you just seven color options. I want to have a promt asking me what tag I want to attribute to the request, exactly as it does for the Spotlight comment action. Is this possible with Automator or should I look elsewhere, like AppleScript?

    I have two solutions to bypass, where the first is a combination of Automator and Hazel (probably consume more memory) where I use the Spotlight comment action in Automator and then let Hazel tag of the file via a dynamic tag (comment Spotlight under 'other' element of choice). But it is almost useless, because if I just replace an existing file, the workflow is not triggered, in this case only if a new file is added. How can I make the workflow work on new and existing files? The same thing happens when I use the alternative workaround, I integrate Quicksilver in an Automator workflow to send the item (file) to Quicksilver if I where he can score. Any suggestion is welcome!

    Thanks in advance!

    With or without Automator, AppleScript script would be the way to go.  You'll have the same problem with actions folder be it, however, they are only triggered when a component is added to a watched folder.

    You can use the URL of cocoa class to add your tags - this topic of the mailing list has the script library routines (note that you can use directly in a script of El Capitan).

  • 3.5 numbers formula "name of the journal.

    He continues to be for me that I need to access the name of a worksheet in a formula.

    The standard solution in Excel is easy to find in several focus groups.

    = Right (Cell("filename",a1), Len (Cell("filename",a1)) - Find ("]", Cell ("filename", a1), 1))

    It is just as easy to understand how to put custom formulas in the cells VBA macros in order to access some of the data that had been pasted from the Clipboard by the same VBA macro. Everyone let me know where to find a documentation full of the interface of automator for the numbers, please?

    I always have a hard time to understand why these useful information are kept secret from me if want to use it as part of the Apple software?

    I don't even want for a complete solution, but just for a general idea that would allow me to continue to understand me.

    Thanks in advance!

    Could you give a general idea of the specific problem you want to solve?  A screenshot would be useful. Wayne explains how here.

    The approximate equivalent of VBA is AppleScript, which can be run in Automator, but is often performed outside the Automator too.  Seethis site for examples of automating AppleScript of numbers as well as the other iWorks applications.  There are other examples to macscripter.net, and of course in these forums.

    You can really have a script paste data and also, if necessary, insert a formula that access to these data, if you can not do UDF (user-defined functions) in number.  They are notoriously slow to no Excel anyway, so no big loss.

    We need more information about what you're trying to do.

    SG

  • How to paste some data from numbers to some placeholders in the Pages using AppleScript and Automator?

    Hello AppleScript and Automator Pros!

    Unique ID Elements Quantity Unit of measure Sum, $ Color Dark?
    1 Pencil 1 Agenda 90.50 P Yes
    2 Pen 150 Agenda 300.23 THERE NO.
    3 Pillow 2 Agenda 400.01 B NO.
    4 Toy 114 Agenda 500.30 R Yes
    5 Repair service N/A N/A 1.00 N/A NO.
    6 Phone 98 Agenda 1986.10 W NO.

    P = purple

    Y = yellow

    B = black

    R = red

    W = white

    It was an example of Document numbers


    Now the example of Document Pages

    [PH for Unique ID] - Ben got: [PH for element], [PH for quantity] [PH for unit of measure], [dark or not PH] [PH for color] for [PH for sum before the comma] $ [PH cents] c.

    When Ben had [PH for quantity] [dark or not PH] [PH for Color] [PH for item tiny first character and changeable if necessary end], he became happy

    Example 1: Allows you to take data from line with Unique ID 1 and that's what it takes to go:

    1 - Ben got: pencil, 1 point, violet dark 50 ° c for $ 90.

    When Ben had 1 Purple Pencil dark, he became happy

    Example 2: Now data row with Unique ID 3 and it is what to get:

    3 - Ben got: Pillow, 2 pieces, blue for $ 400 01b

    When Ben had 2 blue pillows he became happy

    Example 3: Now the data used to row with Unique ID 5 and this is what it takes to get:

    5 - Ben got: repair service, 1 service, for 1$ 00 c complete

    When Ben had 1 repair service complete, he became happy

    Here, I have to change given n/d of the table in numbers and replace quantity with 1 PH, PH for unit of measure with service (no point as in the previous examples) and the PH for color with plenty of example.

  • Service existing AppleScript Automator to cut and paste the same image in a conversation of Messages

    New to Applescript/Automator-

    I want to be able to have a simple shot that will allow me to paste a particular image in a conversation in Messages... It is the same image that I want every time. But I want to avoid having to go to Messages, search for image copy and then turn over Messages to paste.  I didn't need the script to automatically display the message, simply cut and paste of the pictures folder so that I am in Messages in a new message to the existing message thread (it makes no sense to me). Be good for this service in the Messages and be available to a hot key combination!

    You might want to try the following script to copy and paste an image in the images folder. To launch the script with a quick access key, use FastScripts (free up to 10 keyboard shortcuts).

    the value thePictureName to "Test.jpg".

    value thePicture to (path to the folder images as text) & thePictureName as alias

    say application 'Finder '.

    activate

    thePicture reveal

    end say

    delay 1

    say application 'System events' to hit 'c' using {control down}

    say application "Messages".

    activate

    if not visible from the window 1 then

    say application 'System events' to hit '0' using {control down}

    end if

    end say

    delay 1

    say application 'System events' to hit 'v' {control down}

  • Process of renaming with applescript/automator

    Hello

    I need a workflow to automate or an applescript script that will look at a folder called 'Vidéos Finished'. When a video file (.mkv or .mp4) is added to this folder, please proceed as follows:

    1. Create a new folder in the folder «Finished videos»
    2. Rename the new folder in the same as the file that has been added (less the extension)
    3. Copy the file added in this new folder
    4. Delete the added file so it only exists in the new renamed folder.

    Otherwise if it's easier, it would be ok if the new folder is created in a different folder of "destination". Also long video file ends upward in a folder named idental to himself.

    No guest should be presented during the process. He needs run automataically.

    Is it still possible? I hope someone can help :-)

    Kind regards

    Jesper

    It's trivial and actually easier that involves your workflow.

    It requires 2 steps, not 4:

    1: create a folder with the same file name (without extension)

    2: move the file to the new folder

    The trickiest part is the extraction of the base name of the file (without the extension), but this should do the trick:

    on Adding folder items to folder after receiving theNewItems

    Repeat with eachItem in theNewItems

    the value theBaseName to my getBaseNameOf (eachItem)

    say application 'Finder '.

    the value theNewFolder to create a new folder to Folder with properties {name: theBaseName}

    pass to theNewFolder eachItem

    end say

    end Repeat

    end Adding folder items to

    on getBaseNameOf (thisItem)

    say application 'Finder '.

    the value ext for name extension of thisItem

    the value extLength to the number of characters in ext

    the value n to characters 1 through -(extLength + 2) of (get the name of thisItem) as text

    end say

    n return

    end getBaseNameOf

  • AppleScript move files to the specific folder for Automator

    Hello

    I have a script to do a bunch of stuff that makes PDF files that I have stored in different folders. I want to be able to move the items by using a loop

    i.e. repeat with i from 1 to (number of files in the folder x) - assuming that all records have also the same number of files

    move point i of the x to folder toCombine folder

    pass I have folder is the folder toCombine

    pass the z to record toCombine folder i

    Tell application "combines."

    run

    tell the end

    end repeat

    "Handset" is just a simple automator app that takes the contents of the folder of the folder "toCombine" and adds them in the order I want which is X > Y > Z as page 1, 2, and 3. However, I see fluctuations in the order that I continue to work loop while watching the toCombine file, resulting in Z > Y > X and stop randomly.

    I added delay and even a control to see if there is no X before moving the point Y etc..

    Is there a solution for this?

    Just an idea: are you aware that the point of any folder i always refers to the alphabetical order of the Articles?

    For example:

  • Automator - using variables in applescript do script

    How can I insert a variable in 'doing the script' in AppleScript? I want repoName be what is the variable.

    the term {parameters}

    Tell application "Terminal".

    activate

    Set currentTab to script ("ssh [email protected];")

    delay of 6

    do script (' cd... /.. ") ("/ var/www ') in currentTab

    delay of 6

    RepoName text set

    make the script currentTab ('sudo mkdir $repoName")

    tell the end

    end of race

    Figured it out:

    the term {parameters}

    Tell application "Terminal".

    activate

    Set currentTab to script ("ssh [email protected];")

    delay 3

    do script (' cd... /.. ") ("/ var/www ') in currentTab

    delay 3

    Define repoName (enter text)

    do script ('sudo mkdir") & repoName in currentTab

    tell the end

    end of race

    The key is the & symbol, which concatenates.

  • Add File Path as a Spotlight comment to several files using Automator and AppleScript

    Hello

    I would like to add the path of the current directory of files as a comment of built-in projector in each of them, so when I move I know where they where originally.

    I am trying to use the script below:

    the term {parameters}

    Tell application "Finder".

    Repeat with thisfile in entry

    value theComment thisfile POSIX path

    Comment by (thisfile as alias) theComment value

    Back entrance

    tell the end

    end of race

    I get a syntax error: expected 'end' but found 'end tell'.

    Could someone help me please?

    You just forgot the end "repetition":

    Repeat with thisfile in entry

    the value theComment to POSIX path of thisfile

    the value of (thisfile as alias) to theComment comment

    end Repeat

  • Help with applescript or automator.

    Hello

    I want to create a model that asks me for some parameters, and enters in textedit.

    in other words I want the script as or prompts for the user between her text and slap it (in the same line) in editing text. I would also like to choose from the list, and all that is chosen is then also the type in the textedit document (in the same line). Is this possible?

    Thanks in advance

    Use code such as:

    text wrapped the_answer value (display the default dialog box "what text should you like entered?" answer "")

    the_answer the_answer value & "" & (choose from the list {'Option 1', 'Option 2'})

    Tell application "TextEdit".

    defined in paragraph 1 of document 1 (paragraph 1 of document 1) & the_answer

    tell the end

    (142467)

  • Automator leave all

    I want a script to close all open applications and empty the trash.

    Applications and Finder behave differently.

    Automator "Utilities" options appear the best result, so I'm focused there.

    I am able to stop all applications, but the Finder is stubborn

    I can close the Finder components as a group within Automator, but combining this group with the group "Close all Applications" The Automator scripts fails to close the components Finder (Finder, Get info and inspector window).

    Here's what I have so far.

    Group 1: on his own closing everything except the Finder stuff.

    Utilities > quit all applications

    Quit all applications

    Group 2: this group works well.

    Utilities > run AppleScript

    the term {parameters}

    Tell application "Finder".

    empty the trash

    tell the end

    delay 1

    Back entrance

    end of race

    Group 3: run on its own that works, but not with "quit all Applications.

    Utilities > run AppleScript

    the term {parameters}

    Tell application "Finder".

    activate

    quit smoking

    delay 3

    Tell application "Finder".

    activate

    tell the end

    tell the end

    Back entrance

    end of race

    Group 4: it works on its own for Finder stuff, but does not work with other groups.

    Utilities > run Script Shell

    CAT

    osascript-e 'tell application "Finder" to quit smoking.

    I noticed that sometimes the AppleScript works, and a second later it stops working.

    For now, I found a way to make it work. Automator works great Finder asking you to empty the trash. Then I dropped the trash from Group 2 to group 4, the bottom of the collection of Automator. Now it works... for now...

    Group 1: Utilities > quit all applications

    Quit all applications

    Group 2: Utilities > run AppleScript

    the term {parameters}

    Tell application "Finder".

    activate

    quit smoking

    delay 3

    Tell application "Finder".

    activate

    tell the end

    tell the end

    Back entrance

    end of race

    Group 3: Utilities > run Script Shell

    CAT

    osascript-e 'tell application "Finder" to quit smoking.


    Group 4: Utilities > run AppleScript

    the term {parameters}

    Tell application "Finder".

    empty the trash

    tell the end

    delay 1

    Back entrance

    end of race


    If anyone knows why this command works, an explanation would be appreciated.

  • AppleScript to create the thumbnail of the file selected with hyperlink to the URL of the file

    Hello

    I need an AppleScript script to copy to the Clipboard a thumbnail of a selected file (s. picture 1 below) with a hyperlink to the URL of the selected file.

    I have a script that allows me to get the URL of the file and copy it to the Clipboard. But then I have to paste the URL into my Document, back to the finder, make a screenshot of the thumbnail of the file, paste this screenshot and enter the URL (manually copy) of the file (choose the context menu of the image) (s. image 2 below):

    Is there a way to automate this?

    I could do the screenshot manually, this is actually no problem, but then I would need to attribute this screenshot on a Clipboard 1, go back and get the URL of the file and attribute it to Clipboard 2 and then go to my document and paste Clipboard 1 first, chose the menu popup "hyperlink" and the Clipboard paste 2.

    I would be grateful for the help!

    (I am a high school language teacher, and it is a task repetitive Daylilies)

    Kind regards

    Kai - Uwe

    Kai - Uwe,

    OpenOffice or LibreOffice aren't outwardly scriptable with AppleScript or Automator, as to exclude these two applications that support. They are inwardly Python scriptable via their respective SDK.

    I became aware of a solution of AppleScript that invites for the input file, then uses a custom (port) application that uses QuickLook to generate an image thumbnail jpg to your specified output destination. I added a line of AppleScript that sends the URL of the file to the Clipboard.

    After running the script, I can paste the URL of the document in LibreOffice and follow by drag and drop the jpg thumbnail afterwards.

    Do you want me to post the directions for this solution. In its current form, it is not written for processing batch.

  • AppleScript for the development of Documents of numbers

    Hello!

    I just finished my first 'Real' Applescript to do something that I thought was pretty simple.

    It took me 5 days to figure it out!

    In any case, I regularly create new documents of numbers whenever I make a deposit in cash for the accountant of campus

    (I am a teacher/middle school band Director and am constantly receive payments from children for t-shirts, uniform band, travel expenses, etc.)

    I tried for years to find a way to compile all deposit slips in a single document to keep track of who paid for what during the school year and I always ended up having to manually copy and paste the data of each doc in the main list (last year I had more than one hundred different deposits slip files in a folder on my desktop).

    Long story short, I discovered Automator and Applescript a couple weeks ago and have been playing with them. Who would have thought that these tools had been all the time on my mac!

    If someone (much more qualified than me) could take a look at the code, I am come with below to see if she is healthy, of if there is a more effective way to achieve this, I very much appreciate it!

    The code works for now, but if there is something or any weakness that could break it in a future update, I would like to know about it.

    CODE BELOW:

    -------------------------------------------------

    -It is my attempt to create an AppleScript to copy data from several numbers documents and compiling a database for use in a single master Document numbers.

    -The way it's Setup now, whenever a new document data is added to the source folder, I double click on an icon on the desktop that runs this script.

    game of sourceFolder to (POSIX file ' / users/my_name/library/2016-2017 Financial Documents TO BE ADDED / " as alias)

    -source folder for documents to add to the main list


    game of to targetFolder (POSIX file ' / users/my_name/library/2016-2017 Documents financial/DONE / " as alias)

    -Place for documents to go after they are added to the main list.


    game dittos to (Choose file with prompt "choose a numbers Document to copy in the type list." as text by default location sourceFolder)

    -The script will ask me to select a file out of the source folder to copy


    say application "Numbers".

    activate

    the value doc to Open dittos

    say table 1 of the sheet active of the doc

    the value thisRangeName to '03:37.

    -the range I want to copy

    the value the range selection for range thisRangeName

    -selects the range I want to copy

    end say

    end say

    say application 'System events' to hit 'c' with the command down

    -copy the selected to the Clipboard.

    property docTarget: "/ users/my_name/library/2016-2017 band Documents/2016-2017 student List.numbers.

    -The location of the master file

    property today: current date

    -variable to use when entering information in the master file. This helps to sort the objects added to the master file.


    say application "Numbers".

    Open docTarget

    say 1 of table sheet "Sums of MONEY RECOVERABLE" of front document

    Add the line below last line

    -creates a new line to receive new information.

    the value the value of the last first cell at (today's date) string a line

    -between the current date in the first column of the table

    set the selection go in last second cell line

    -moves the selected cell to the one who will receive the data from the Clipboard.

    say application 'System events' to hit 'v' with the command down

    -Paste the Clipboard data

    say application "System events" of typing "ESC".

    -Deletes the currently selected cells

    end say

    -We will now check for empty lines that have been pasted from the source document to clean our Master Document.

    say 1 of table sheet "Sums of MONEY RECOVERABLE" of front document

    Set rowCount to (each line of the selection between)

    -the number of rows to check? Number of rows is determined by the amount of the previous selection range.

    Repeat with I of 3 for the count of number of lines

    -ignore the first 2 rows, which are header lines, the County

    the value may be to (value of fifth cell in last line)

    -checks the value of the fifth column (reason for the activity) to see if it is empty.

    If perhaps missing value then set went to last row

    -from the last line of the document, if the fifth column is blank, it is marked for deletion.

    Remove gone

    -remove the empty line

    end Repeat

    the value is in (value of fifth cell in last line)

    -When the repeated destruction are complete, if there is an extra empty line remains, it will get.

    If done then delete last rank missing value

    -the if statement that will remove the last extra line

    end say

    end say

    quit smoking application "Numbers".

    -close all documents of numbers and quit the application

    say application 'Finder '.

    move File to the folder targetFolder Dittos

    -move the Source file out of the folder "TO BE ADDED" and in the "DONE" folder.

    end say


    --------------------------------------------------


    Thanks for the help and advice of an Applescript Newbie!

    -Jimforxst

    First of all, if the script works for you, then it's good enough

    Even experienced/veteran AppleScripters can spend a lot of time to 'perfect' scripts, so it is important to balance the how long it will take to arrive at a solution that is "perfect".

    If you're looking for pointers that might work "better", here are a few thoughts.

    First of all, your script depends on literally copy and paste the data from the source file for the master file. I'm never a fan of this approach. All works (clearly), it is prone to error and changes the State of the system - not sure if what was in the Clipboard the script at startup has been sought, and the operator (if it wasn't you) do not doubt that the execution of the script would change the contents of the Clipboard. In general, I think it's better to reference the data directly ("set data2Copy to (get the ranks 1 to 37 of table 1...)"), although it works for now.

    In addition, your script is depends somewhat on the specifics of the source and master files. There is no error checking that the source data is valid before you copy it.

    On the same topic, you have a significant amount of code to check if the column 5 is empty. I would consider doing this check at the front - in other words only copies the data you need, rather than copy more and must clean up afterwards. Once again, the details of this function a bit on the data.

    Finally, for the moment, the script runs on a single file at a time - opens the source file, opens the master file, copies the data, close the files and closes way unexpected numbers.

    What happens if there are multiple source files to process? You can consider a loop through the files, the copied data and closing/smoke right at the end. That would save some time.

  • How to transfer GPS coordinates from one film to the other using Applescript?

    When I export a movie from the Photos app and read it in Quicktime Player.

    QTP then gives me the location where the film was saved:

    Now, I would like to set the location of another movie in exactly in the same place, using Automator or Applescript.

    Could someone please give me a tip how to do this? Is this possible?

    The reason why I want to do is I want to improve an Automator workflow, I wrote which helps the compression of movies that I keep in my library of Photos (that is, to reduce the size of the file).

    The workflow, you can find here (http://www.informatik.uni-bremen.de/~zach/software/index.html#compress_movies_in _photos), if you are interested.

    Tips, pointers and suggestions will be highly appreciated.

    Best regards

    Gabriel.

    Hard to do standalone AppleScript, but easy if you install a copy of exiftool

    Then, you can extract the GPS coordinates via something like:

    the shell script "" / usr/local/bin/exiftool - GPSPosition some. "." JPG ".

    You can also use exiftool to copy the tags of one file to another:

    the shell script ' / usr/local/bin/exiftool - tagsFromFile - GPSLongitude source.jpg - GPSLatitude dest.jpg.

    This will copy the tags GPS Longitude and Latitude of source.jpg to dest.jpg

  • Automator is missing in action 'PDF Split'

    I can't find the Automator action: 'PDF Split' - it is mentioned in this article: http://www.documentsnap.com/how-to-split-pdf-documents-into-single-pages-using-m ac - osx / #comment-280641 which has many comments confirming the existence of this action.

    I read the post here about the missing "extract PDF Text" action, but the solution it does not solve my problem.

    I can't find the 'Split PDF' automator action on my iMac (early 2009 model) under OS X 10.9.5 (Mavericks).

    At one point I thought that the action "PDF Split" perhaps were renamed "PDF d'Images', which also separates the PDF documents in single page files. Unfortunately, as the name of the action, suggests this automator action creates Images of each page and all previously available text in the PDF document is converted in the process. This makes their subsequent treatment very difficult.

    Any help in recovering this missing action or a workaround (in automator or applescript) would be greatly appreciated!

    On OS X 10.11.6 there is a PDF Split action in PDF Library of Automator. Don't have 10.9.5 to check it of there or not, but Apple doesn't change very often, these actions so that you may have overlooked it.

Maybe you are looking for

  • How to spend the last $ 0.06?

    Hi all, I'm going to go back to China in a week so my Apple ID region will be changed to the Australia to China. However, my account were still $ 0.06. Can someone tell me how to spend this last $ 0.06?

  • "Update security settings" mail exchange

    I looked and I do not think that someone posted a fix or a solution to the problem. On each droid initialize. The error message "Update security settings" appears in bar. I click on the message and nothing happens. It took me before on my corporate e

  • Can I replace a Keyboard(Non-Backlit) with backlit keyboard on my HP Pavilion DV6 3217TU laptop. ??

    Hi all... My name Pravin and I own a HP PAVILION DV6-3217TU laptop a few years ago.Well, when I visited one near Center of HP customer service for replacement of some components in this document, the HP technician told me that my HP PAVILION DV6 - 32

  • Windows XP OEM EULA (Pavilion a400y)

    My father-in-law has a hp Pavilion a400y with Win XP (SP1) OEM which is really slow. If I'm working him up to 2 GB of memory and to change its processor Celeron to a faster processor of the same socket /(bus bandwidth) will disable I its MS Windows O

  • Driver problems - code 28

    I have windows 7 PC All of a sudden my computer has decided that my ipod nano is not all drivers. I tried to reinstall iTunes, reset the ipod.  Passed through the Device Manager and asked to look for the driver. I have an another nano (which has a sc