Acrobat Sort By Size
Acrobat Sort By Size
- Subject: Acrobat Sort By Size
- From: Trisha Davidson <email@hidden>
- Date: Fri, 14 Dec 2012 10:33:36 -0600
- Thread-topic: Acrobat Sort By Size
Title: Acrobat Sort By Size
Hello! I'm trying to create a script that, when a folder is dropped on it, will open the enclosed PDF's in Acrobat, check the size and do a save as to the appropriate folder.
For example: If the PDF is {0, 468, 684, 0} it should save as to the 0_Flat folder created earlier in the script, without changing the file name, and other sizes will go to the 0_Folded folder. When I run my script it acts like it will work until it comes to the save, then it errors saying that the document or Acrobat doesn't understand the save message.
I'm very new to Applescripting, any pointers would be greatly appreciated. Thank you!!
Trisha
Here is my script:
on open aList
with timeout of (30 * minutes) seconds
set CustFolder to item 1 of aList
tell application "Finder"
set AppleScript's text item delimiters to {":"}
set PathList to text items of (aList as text)
set PathCount to count of items in PathList
set AppleScript's text item delimiters to {""}
set OriginalfileList to name of every file of CustFolder
set fileCount to count of items in OriginalfileList
set FlatFolder to (CustFolder & "0_Flat:") as string
set FoldFolder to (CustFolder & "0_Folded:") as string
set FlatFile to (FlatFolder)
set FoldFile to (FoldFolder)
try
set FlatFolder to make new folder at alias CustFolder with properties {name:"0_Flat"}
end try
try
set FoldFolder to make new folder at alias CustFolder with properties {name:"0_Folded"}
end try
try
set OriginalFolder to make new folder at alias CustFolder with properties {name:"0_Original"}
end try
repeat with t from 1 to fileCount
set saveNo to "Yes"
tell application "Adobe Acrobat Pro"
set theDocA to item t of OriginalfileList
open ((CustFolder & theDocA) as string)
tell document theDocA
tell page 1
set {0, theHeight, theWidth, 0} to bleed box
set the_number_to_round to theHeight
set the_decimal_precision to 1
my round_to_decimal_places(the_number_to_round, the_decimal_precision)
set theHeight to result
set the_number_to_round to theWidth
set the_decimal_precision to 1
my round_to_decimal_places(the_number_to_round, the_decimal_precision)
set theWidth to result
end tell
end tell
if theHeight is 468 and theWidth is 684 then
set FlatFile to (FlatFolder)
else
set FoldFile to (FoldFolder)
end if
save document theDocA with linearize
close document theDocA saving no
end tell
end repeat
tell application "Finder"
repeat with i in OriginalfileList
move i to folder "0_Originals" of CustFolder
end repeat
display dialog "UHG script has completed successfully."
end tell
end tell
end timeout
end open
on round_to_decimal_places(the_number_to_round, the_decimal_precision)
set multiplier to 10 ^ the_decimal_precision
the_number_to_round * multiplier
round result
return result / multiplier
end round_to_decimal_places
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden