Impossibile eseguire
I seguenti sono diversi modi per richiedere i file. Non c'è modo, in puro Apple Script , di richiedere contemporaneamente le cartelle File o .
Seleziona file :
set directory to POSIX path of (choose file with prompt "File Location:" default location (path to desktop))
Seleziona file :
set directory to POSIX path of (choose file with prompt "File Location:" default location (path to desktop) with multiple selections allowed)
Seleziona cartella :
set directory to POSIX path of (choose folder with prompt "File Location:" default location (path to desktop))
Seleziona cartelle :
set directory to POSIX path of (choose folder with prompt "File Location:" default location (path to desktop) with multiple selections allowed)
Seleziona tipi di file specifici:
Prompting for a Specific Type of File
If your script requires specific types of files for processing, you
can use the choose file command’s optional of type parameter to
provide a list of acceptable types. Types may be specified as
extension strings without the leading period (such as "jpg" or "png")
or as uniform type identifiers (such as "public.image" or
"com.apple.iwork.pages.sffpages"). Listing 26-3 and Listing 26-4 show
how to prompt for an image.
Per immagini:
set directory to POSIX path of (choose file of type {"public.image"} with prompt "File Location:" default location (path to desktop) with multiple selections allowed)
Fonti: Mac Scripting Automation Guide
Usando AppleScriptObjC puoi chiedere File o Cartelle. Vedi questa risposta (se la risposta collegata ti ha aiutato, per favore, aumenta la Q & A collegata):
No, you can't do it with "choose file" or "choose folder" verbs, but
choosing a file or folder (or multiple files/folders) is supported
by the underlying NSOpenPanel
. So you can do it with
AppleScriptObjC. Here's an example using [ASObjCRunner][1] (derived
from [here][2]):
script chooseFilesOrFolders
tell current application's NSOpenPanel's openPanel()
setTitle_("Choose Files or Folders") -- window title, default is "Open"
setPrompt_("Choose") -- button name, default is "Open"
setCanChooseFiles_(true)
setCanChooseDirectories_(true)
setAllowsMultipleSelection_(true) -- remove if you only want a single file/folder
get its runModal() as integer -- show the panel
if result is current application's NSFileHandlingPanelCancelButton then error number -128 -- cancelled
return URLs() as list
end tell
end script
tell application "ASObjC Runner"
activate
run the script {chooseFilesOrFolders} with response
end tell
ASObjCRunner converts a NSArray
of NSURL
objects into an
AppleScript list of file
s; the results can look something like:
{file "Macintosh HD:Users:nicholas:Desktop:fontconfig:", file "Macintosh HD:Users:nicholas:Desktop:form.pdf"}
[1]: http://www.macosxautomation.com/applescript/apps/runner.html
[2]: https://stackoverflow.com/questions/8125563/
Potresti utilizzare una finestra di dialogo che richiede a un utente di selezionare ciò che vorrebbero criptare.
display dialog "Select a type to Encrypt" buttons {"File(s)", "Folder(s)"}
set a to the button returned of the result
if a is "File(s)" then
set directory to POSIX path of (choose file with prompt "File Location:" default location (path to desktop) with multiple selections allowed)
else
set directory to POSIX path of (choose folder with prompt "File Location:" default location (path to desktop) with multiple selections allowed)
end if
Infine, controlla la mia risposta qui per un modo per crittografare i file con Apple Script e Automator.