0 votos

"No se pueden convertir "documentos" en números enteros de tipo." -1700

He estado haciendo un guión simple para mi hermana, pero no funciona. ¿Requiere un número entero? No lo especificé en mi programa, ¿pero lo llama de todos modos?

activate
display dialog "Click Start to start importing your own kindle books!" with title "Kindle Book Uploader by Jeremy Zhang" buttons {"Cancel", "Start"} default button "Start"

property documentFolder : "documents"

tell application "Finder" to (get name of every disk whose ejectable is true)
try
    set kindleLocation to ¬
                ((choose from list result with prompt "Select your Kindle from the list:") as text)
end try

try
      set bookFiles to ¬
                ((choose file with prompt ¬
                          "Select kindle files to import:" of type {"public.html", "public.rtf", "com.microsoft.word.doc", "public.data.mobi", "public.plain-text", "com.adobe.pdf"} with multiple selections allowed) as text)
end try

display dialog "Please wait while the application copies the kindle books..." with title "Kindle Book Uploader by Jeremy Zhang"

tell application "Finder"
      if not (exists folder documentFolder of kindleLocation) then
  make new folder at kindleLocation with properties {name:documentFolder}
      end if
end tell

set fullKindlePath to POSIX path of (kindleLocation as alias) & "documents"

tell application "Finder"
 move (bookFiles) to fullKindlePath
end tell

display dialog "Process has been done! Please eject your kindle and the files will be on the home screen of your Kindle." with title "Kindle Book Uploader by Jeremy Zhang"

Y el resultado de ejecutarlo:

tell current application
 activate
end tell
tell application "AppleScript Editor"
 display dialog "Click Start to start importing your own kindle books!" with title "Kindle Book Uploader by Jeremy Zhang" buttons {"Cancel", "Start"} default button "Start"
  --> {button returned:"Start"}
end tell
tell application "Finder"
 get name of every disk whose ejectable = true
  --> {"JEREMY DISK"}
end tell
tell application "AppleScript Editor"
 choose from list {"JEREMY DISK"} with prompt "Select your Kindle from the list:"
  --> {"JEREMY DISK"}
 choose file with prompt "Select kindle files to import:" of type {"public.html", "public.rtf", "com.microsoft.word.doc", "public.data.mobi", "public.plain-text", "com.adobe.pdf"} with multiple selections allowed
  --> {alias "Macintosh HD:Users:JeremyZhang:Downloads:5 ETS SAT S.pdf"}
 display dialog "Please wait while the application copies the kindle books..." with title "Kindle Book Uploader by Jeremy Zhang"
  --> {button returned:"OK"}
Result:
error "Can't make \"documents\" into type integer." number -1700 from "documents" to integer

¿Qué estoy haciendo mal?
AppleScript Editor 2.5 (138)
AppleScript 2.2.3

1voto

Tony Williams Puntos 4903

Las alegrías de escribir variables en AppleScript. Creo que tu problema está en la línea

set fullKindlePath to POSIX path of (kindleLocation as alias) & "documents"

Intentaría cambiar esto a

set fullKindlePath to (the POSIX path of (kindleLocation as alias)) & "documents"

entonces si eso no funciona, intente & ("documents" as POSIX PATH)

Por cierto, ¿estás seguro de que fullKindlePath %-% tiene un '/' al final?

AppleAyuda.com

AppleAyuda es una comunidad de usuarios de los productos de Apple en la que puedes resolver tus problemas y dudas.
Puedes consultar las preguntas de otros usuarios, hacer tus propias preguntas o resolver las de los demás.

Powered by:

X