• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Acrobat Sort By Size
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Acrobat Sort By Size


  • Subject: Re: Acrobat Sort By Size
  • From: Trisha Davidson <email@hidden>
  • Date: Tue, 18 Dec 2012 09:38:15 -0600
  • Thread-topic: Acrobat Sort By Size

Title: Re: Acrobat Sort By Size
If anyone is curious, I got this script to work. Thank you for the help James!!

Here is the final code:

on open aList
   with timeout of (30 * minutes) seconds
       set CustFolder to item 1 of aList
       tell application "Finder"
            set PathCount to count of items in aList
           set OriginalfileList to name of every file of CustFolder
           set fileCount to count of items in OriginalfileList
           set FlatFolder to make new folder at alias CustFolder with properties {name:"0_Flat"}
            set FoldFolder to make new folder at alias CustFolder with properties {name:"0_Folded"}
            set OriginalFolder to make new folder at alias CustFolder with properties {name:"0_Original"}
            set RightFolder to make new folder at FoldFolder with properties {name:"0_Right"}
            set LeftFolder to make new folder at FoldFolder with properties {name:"0_Left"}
            --set current view of container window of CustFolder to list view
           set current view of container window of every folder of CustFolder to list view --or column view etc
           (open folder CustFolder) activate
           duplicate files of folder CustFolder to OriginalFolder
           ---------------------------------
           repeat with t from 1 to fileCount
               tell application "Adobe Acrobat Pro"
                    activate
                   set theDocA to item t of OriginalfileList
                   open ((CustFolder & theDocA) as string) with invisible
                   --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 mydoc to active doc
                       set mydoc to document 1
                        set myCustFolder to POSIX path of (CustFolder)
                        set NewPdf to myCustFolder & theDocA
                       tell mydoc
                           save to POSIX file NewPdf with linearize
                       end tell
                        close front document saving no
                       tell application "Finder"
                            set AllFiles to (files of folder CustFolder whose name is theDocA)
                            duplicate AllFiles to FlatFolder
                           delete AllFiles
                       end tell
                        ---------------------------------
                   else
                        --set mydoc to active doc
                       set mydoc to document 1
                        set myCustFolder to POSIX path of (CustFolder)
                        set NewPdf to myCustFolder & theDocA
                       tell mydoc
                           save to POSIX file NewPdf with linearize
                       end tell
                        close front document saving no
                       tell application "Finder"
                            set AllFiles to (files of folder CustFolder whose name is theDocA)
                            duplicate AllFiles to FoldFolder
                           delete AllFiles
                       end tell
                    end if
                end tell
            end repeat
            
            tell application "Finder"
                set fileList to every file of FoldFolder
               repeat with i in fileList
                   if (name of i) does not end with "_p2.pdf" then
                        move i to folder "0_Left" of FoldFolder
                   end if
                end repeat
                try
                    duplicate every file of folder "0_Left" of FoldFolder to folder "0_Right" of FoldFolder --    LeftFolder to folder RightFolder
               end try
            end tell
            
            
            tell application "Finder"
                set leftList to every file of LeftFolder
               repeat with leftfile in leftList
                   set l to name of leftfile
                   if l ends with ".pdf" then
                        set l to (text 1 through -5 of l) & "_L" & ".pdf" as string
                       set name of leftfile to l
                   end if
                end repeat
                --    end tell
               
                --    tell application "Finder"
               set rightList to every file of RightFolder
               repeat with rightfile in rightList
                   set r to name of rightfile
                   if r ends with ".pdf" then
                        set r to (text 1 through -5 of r) & "_R" & ".pdf" as string
                       set name of rightfile to r
                   end if
                end repeat
            end tell
            activate
           display dialog "UHG script has completed successfully." giving up after 2
        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



On 12/14/12 11:45 AM, "James Yanchak" <email@hidden> wrote:

Trisha,

Acrobat has very little scripting support, so is usually a nightmare to work with. Try moving the save command into the document tell.  I have found newer versions of Acrobat do not recognize documents stored as variables.  I use the following handler:

my Acrobat_File_Close("Yes")

# closes PDF file #1, SaveValue (yes, true, Save) determines if file should be saved.
on Acrobat_File_Close(SaveValue)
set ListSaves to {true, "yes", "Save", "keep", "y", "true"}
tell application "Adobe Acrobat Pro"
tell document 1
if ListSaves contains SaveValue then
close saving yes
else
close saving no
end if
end tell
end tell
end Acrobat_File_Close

Just us the "my" line each time you want to save a document. For safety, the document should be the only open one in Acrobat.

James

On Dec 14, 2012, at 11:33 AM, Trisha Davidson wrote:

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



 _______________________________________________
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

  • Prev by Date: Re: iTunes 11 - how does it works with pre existing applescripts?
  • Next by Date: How to modify Grid Spacing ?
  • Previous by thread: Re: Acrobat Sort By Size
  • Next by thread: Getting PowerPoint Slide Info
  • Index(es):
    • Date
    • Thread