Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

vloryan

macrumors member
Original poster
Jan 11, 2014
57
0
hi guys, i would like to shrink pdfs from a specific folder using a droplet and SHRINKPDF (http://www.macupdate.com/app/mac/9206/pdf-shrink). I cannot open all PDFs from that folder at once because SHRINKPDF can handle only one at a time. Now: how can i solve this using APPLE SCRIPT and AUTOMATOR?

> Shrink all PDFs from folder XY with SHRINKPDF.
> Open ONE PDF with that droplet
> Open NEXT PDF with that droplet as soon as LAST PDF finished shrinking

Hope you guys know what i mean :)

Thanks for your help!
 
Hope you guys know what i mean :)

Thanks for your help!

No not exactly. Have you looked at the PDF Shrink 4 User Guide?

4.4 Working with Droplets
A droplet is a small Applescript application that process files that are dropped on to it. PDF Shrink has the ability to create droplets that will optimize PDF documents using a specified configuration. To create a droplet, highlight your configuration in the document manager and click
the Save as Droplet button. You will be prompted to name the script.
Click save to complete creation of the droplet. You can place the droplet anywhere you like. Once a droplet is created, you can drag and drop PDFs on the droplet in order to process them.
 
problem is that when as soon as more than one file uses the droplet at the same time, only the very first file will be shrinked. others are ignored. that is why i'd like to have the use the droplet one by one. :(
 
problem is that when as soon as more than one file uses the droplet at the same time, only the very first file will be shrinked. others are ignored. that is why i'd like to have the use the droplet one by one. :(

I made a test droplet in PDF Shrink Version 4.8 (Build 9518) and dropped 5 PDF files on it. Works just fine here. I even made a screen recording to show it in action.
 

Attachments

  • Screen Shot 2014-08-01 at 00.41.52.png
    Screen Shot 2014-08-01 at 00.41.52.png
    101.8 KB · Views: 110
  • Screen Shot 2014-08-01 at 00.55.47.png
    Screen Shot 2014-08-01 at 00.55.47.png
    47.7 KB · Views: 110
  • PDF Shrink Test.zip
    2 MB · Views: 384
thanks for your efforts. using several files at once manually on that droplet works, yes. but using an folder action in AUTOMATOR, only the first file will be shrinked. All other files are using the droplet while the first file gets shrinked and are then ignored. That is my problem ;(
 
thanks for your efforts. using several files at once manually on that droplet works, yes. but using an folder action in AUTOMATOR, only the first file will be shrinked. All other files are using the droplet while the first file gets shrinked and are then ignored. That is my problem ;(

You should have mentioned that in your first post. Anyway, here's a possible solution :

In Automator create folder action :

  1. Folder Action receives files and folders added to your folder
  2. Run AppleScript action with the following code

    Code:
    on run {input, parameters}
    	(* Your script goes here *)
    	tell application "Finder" to set theFolder to get container of first item of input
    	-- This should make the folder action wait until files have finished copying to the folder
    	set fSizes to {0}
    	repeat
    		tell application "System Events" to set end of fSizes to size of theFolder
    		if (item -1 of fSizes) = (item -2 of fSizes) then exit repeat
    		delay 1
    	end repeat
    	-- Change to where your droplet app is located. Mine is in the Documents folder
    	tell application "Finder"
    		open input using application file "PDF Shrink Droplet.app" of folder "Documents" of folder "kryten" of folder "Users" of startup disk
    	end tell
    	
    	activate application "PDF Shrink"
    	delay 1
    	tell application "System Events"
    		tell process "PDF Shrink"
    			-- Check to see if the Active button is focused to count the rows
    			if focused of radio button "Active" of tab group 1 of window "Queue" is false then
    				set focused of radio button "Active" of tab group 1 of window "Queue" to true
    			end if
    			-- Wait until all files are processed
    			repeat while (count rows of table 1 of scroll area 1 of tab group 1 of window "Queue") > 0
    				delay 1
    			end repeat
    		end tell
    	end tell
    	
    	return input
    end run
  3. Move Finder Items to Trash

Note : Tested on OS X 10.9.4. You'll need to allow Folder Actions Dispatcher to control your computer. I'm stressing that I dropped files into the hot folder. If you want to process folders as well you'll need to change the script. It is good practice to leave the hot folder empty after processing. This avoids repeated application of the action to the same files.
 

Attachments

  • Screen Shot 2014-08-02 at 02.01.35.png
    Screen Shot 2014-08-02 at 02.01.35.png
    122.3 KB · Views: 154
  • Screen Shot 2014-08-02 at 02.17.14.png
    Screen Shot 2014-08-02 at 02.17.14.png
    26.8 KB · Views: 148
  • Screen Shot 2014-08-02 at 02.19.35.png
    Screen Shot 2014-08-02 at 02.19.35.png
    116.6 KB · Views: 134
  • PDFShrinkFolderAction.zip
    2 MB · Views: 122
Last edited:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.