Remember to maintain security and privacy. Do not share sensitive information. Procedimento.com.br may make mistakes. Verify important information. Termo de Responsabilidade
AppleScript é uma linguagem de script desenvolvida pela Apple que permite aos usuários automatizar tarefas no macOS. É uma ferramenta poderosa para aumentar a produtividade e realizar tarefas repetitivas de maneira eficiente. Este artigo abordará como criar scripts automatizados no macOS usando AppleScript, sua importância e fornecerá exemplos práticos para ajudar você a começar.
Exemplos:
-- Este script abre o Safari e o TextEdit
tell application "Safari"
activate
end tell
tell application "TextEdit"
activate
end tell
Para executar este script:
-- Este script renomeia todos os arquivos em uma pasta específica
set targetFolder to choose folder "Escolha a pasta contendo os arquivos a serem renomeados:"
set newNamePrefix to text returned of (display dialog "Digite o novo prefixo para os arquivos:" default answer "")
tell application "Finder"
set fileList to every file of targetFolder
repeat with i from 1 to number of items in fileList
set oldName to name of item i of fileList
set newName to newNamePrefix & (i as string) & "." & name extension of item i of fileList
set name of item i of fileList to newName
end repeat
end tell
Para executar este script:
-- Este script envia um e-mail usando o Mail.app
set recipientName to "Nome do Destinatário"
set recipientAddress to "email@example.com"
set theSubject to "Assunto do E-mail"
set theContent to "Conteúdo do E-mail"
tell application "Mail"
set newMessage to make new outgoing message with properties {subject:theSubject, content:theContent, visible:true}
tell newMessage
make new to recipient at end of to recipients with properties {name:recipientName, address:recipientAddress}
send
end tell
end tell
Para executar este script: