Hallo Martin,
nun ... ich habe keine Probleme mit der Zeile 'save document doc1 to newFile with linearize'.
Aber der Befehl 'set fileList to (sort fileList by name) as alias list' mit welchem der Finder die Liste der Pfade
sortieren soll, löst eine Fehlermeldung aus. Vielleicht ist das Sortieren in Mac OS 10.3.5 möglich.
Aber im 10.3.4, welches ich benutze, steht im Verzeichnis: (NOT AVAILABLE YET).
Ich habe deshalb einen QuickSort-Handler eingebaut. Und dieses Script funktioniert:
---
on open fileList
set fileCount to (count of fileList)
set newFile to choose file name with prompt "Name der neuen PDF-Datei:" default name "Datei" & fileCount & ".pdf"
tell application "Acrobat 6.0 Professional"
activate
end tell
set stringList to {}
repeat with i from 1 to fileCount
set end of stringList to (item i of fileList) as string
end repeat
set fileList to my quickSort(stringList, 1, fileCount)
tell application "Finder" to set doc1 to name of ((item 1 of fileList) as alias)
tell application "Acrobat 6.0 Professional"
open (item 1 of fileList) with invisible
set fileList to rest of fileList
repeat with aFile in fileList
tell application "Finder" to set doc2 to name of (aFile as alias)
try
set pageCount to count each PDPage of document doc1
open aFile with invisible
set pageCount2 to count each PDPage of document doc2
insert pages document doc1 from document doc2 starting with 1 number of pages pageCount2 after pageCount
close document doc2 saving no
end try
end repeat
save document doc1 to newFile with linearize
display dialog "Fertig." buttons "OK" default button 1 with icon 1 giving up after 1
end tell
end open
on quickSort(a, L, R)
script
property aList : a
end script
tell result
set ctr to L
set n to R
set aRef to item L of its aList
repeat while ctr < n
repeat while (aRef < item n of its aList) and (ctr < n)
set n to n - 1
end repeat
if n is not ctr then
set item ctr of its aList to item n of its aList
set ctr to ctr + 1
end if
repeat while (aRef > item ctr of its aList) and (ctr < n)
set ctr to ctr + 1
end repeat
if n is not ctr then
set item n of its aList to item ctr of its aList
set n to n - 1
end if
end repeat
set item n of its aList to aRef
if L < n then
quickSort(its aList, L, n - 1)
end if
if R > ctr then
quickSort(its aList, ctr + 1, R)
end if
return its aList
end tell
end quickSort
---
Das Wörtchen 'file' brauche ich demnach nicht. Kann aber auch sein, dass mir die Scripting Addition "Jon's Commands.osax" reinfunkt.
Hans Haesler <hsa@ringier.ch>
als Antwort auf: [#418828]