Re: Apple Script to combine the multiple pdf files as single pdf file
Re: Apple Script to combine the multiple pdf files as single pdf file
- Subject: Re: Apple Script to combine the multiple pdf files as single pdf file
- From: KOENIG Yvan <email@hidden>
- Date: Sun, 03 Apr 2011 22:12:51 +0200
--{code}
--[SCRIPT join_PDFs]
(*
Enregistrer le script en tant que Script : join_PDFs.scpt
déplacer le fichier ainsi créé dans le dossier
<VolumeDeDémarrage>:Users:<votreCompte>:Library:Scripts:
aller au menu Scripts , puis choisir join_PDFs
Vous pouvez également enregistrer le script en tant qu'application.
Vous pourrez alors glisser déposer les icônes de PDFs à fusionner sur celle du script.
J'ai trouvé le code principal dans une page Web.
--=====
L'aide du Finder explique:
L'Utilitaire AppleScript permet d'activer le Menu des scripts :
Ouvrez l'Utilitaire AppleScript situé dans le dossier Applications/AppleScript.
Cochez la case "Afficher le menu des scripts dans la barre de menus".
Sous 10.6.x,
aller dans le panneau "Général" du dialogue Préférences de l'Éditeur Applescript
puis cocher la case "Afficher le menu des scripts dans la barre des menus".
--=====
Save the script as a Script: join_PDFs.scpt
Move the newly created file into the folder:
<startup Volume>:Users:<yourAccount>:Library:Scripts:
go to the Scripts Menu, choose Numbers, then choose "join_PDFs"
You may also save the script as an application.
Then you will be anle to drag an drop PDFs icons on the script one.
I found the main code in a Web page.
--=====
The Finder's Help explains:
To make the Script menu appear:
Open the AppleScript utility located in Applications/AppleScript.
Select the "Show Script Menu in menu bar" checkbox.
Under 10.6.x,
go to the General panel of AppleScript Editor’s Preferences dialog box
and check the “Show Script menu in menu bar” option.
--=====
Yvan KOENIG (VALLAURIS, France)
2011/01/18
*)
--=====
on run
if parle_anglais() then
set les_fichiers to choose file "Select the PDFs files to merge" of type {"com.adobe.pdf"} with multiple selections allowed without invisibles
else
set les_fichiers to choose file "Sélectionner les fichiers PDFs à fusionner" of type {"com.adobe.pdf"} with multiple selections allowed without invisibles
end if
my main(les_fichiers)
end run
--=====
on open sel
my main(sel)
end open
--=====
on main(lesPDFs)
local p2s, alias_existe, aPath, chemin_du_nouveau_PDF, les_UNIXs
set lesPDFs to lesPDFs as list -- just for safe
set p2s to "" & (path to startup disk)
tell application "System Events" to set alias_existe to exists disk item (p2s & "joinPDF.py")
(*
If it doesn't exist, create a symbolic link to a python script
delivered by Apple in an Automator process.
*)
if not alias_existe then
set aPath to quoted form of "/System/Library/Automator/Combine PDF Pages.action/Contents/Resources/join.py"
do shell script "ln -s " & aPath & " joinPDF.py"
end if
set chemin_du_nouveau_PDF to "" & (path to documents folder) & (do shell script "date +_%Y%m%d-%H%M%S") & ".pdf"
set les_UNIXs to {}
repeat with i from 1 to count of lesPDFs
copy quoted form of POSIX path of item i of lesPDFs to end of les_UNIXs
end repeat
set les_UNIXs to my recolle(les_UNIXs, space)
do shell script "./joinPDF.py -o " & quoted form of POSIX path of chemin_du_nouveau_PDF & space & les_UNIXs
tell application "Finder" to open file chemin_du_nouveau_PDF
end main
--=====
on recolle(l, d)
local oTIDs, t
set oTIDs to AppleScript's text item delimiters
set AppleScript's text item delimiters to d
set t to l as text
set AppleScript's text item delimiters to oTIDs
return t
end recolle
--=====
on parle_anglais()
return (do shell script "defaults read 'Apple Global Domain' AppleLocale") does not start with "fr_"
end parle_anglais
--=====
--[/SCRIPT]
--{code}
Yvan KOENIG (VALLAURIS, France) dimanche 3 avril 2011 22:12:47
_______________________________________________
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