Post marked as unsolved
155
Views
So I have a shell script called > tm.sh which gets the last time time machine successfully backed.
This works fine in the shell,
script editor,
automator
doesn't work as a calendar alarm.
I'm unsure why the "do shell script" line is not working
tm.sh
#!/bin/sh
enabled=`/usr/bin/defaults read /Library/Preferences/com.apple.TimeMachine AutoBackup`
if [ "$enabled" == "1" ];then
lastBackupTimestamp=`date -j -f "%a %b %d %T %Z %Y" "$(/usr/libexec/PlistBuddy -c "Print Destinations:0:SnapshotDates" /Library/Preferences/com.apple.TimeMachine.plist | tail -n 2 | head -n 1 | awk '{$1=$1};1')" "+%Y-%m-%d %H:%M:%S"`
echo "$lastBackupTimestamp"
else
echo "<result>Disabled</result>"
fi
My calendar alarm
Automator > New > Calendar alarm > run apple script
Calendar Alarm AppleScript
on callDateSeperator(dateChange)
set yN to text 1 thru 4 of (dateChange as text)
set mN to text 6 thru 7 of (dateChange as text)
set dN to text 9 thru 10 of (dateChange as text)
return {yN, mN, dN}
end callDateSeperator
on run {input, parameters}
set timeMachineLastDate to (do shell script "sh ~/Desktop/tm.sh")
set tmDate to callDateSeperator(timeMachineLastDate)
display dialog (item 1 of tmDate) & (item 2 of tmDate) & (item 3 of tmDate)
return input
end run
I have given full disk access to automator
calendar
error: this error comes because "timeMachineLastDate" has no value.
The action: "Run AppleScript" encountered an error: Can't get text 1 thru 4 of ""."
Post marked as unsolved
54
Views
Какое обновления установить чтоб поставить чтоб все сбросить на дефаулт, предыдущие владелец пользовался разброткой а я не хочу подскажите что делать как быть,жду помощи спасибо за ранее.
Post marked as unsolved
77
Views
Hey everyone,
that's my first post 🐣
I'm trying to create a services that lets me add highlighted text into an existing note on the notes app using the keyboard shortcuts control+W and also have it in show up under the services menu. I think the script itself (attached below) is working. when I try to use it outside of automator I'm getting this access permission error :
The action “Run AppleScript” encountered an error: “System Events got an error: Automator workflow Runner (WorkflowServiceRunner, WIDK) is not allowed to send keystrokes”
the services isn't showing up in the right click menu. the first script I created using automator actually added the services to the service right click menu but any it disappeared and I don't seem to be able to add new services.
when I open automator after saving and closing it, I can't locate the services I saved, it's not showing up in the finder window of existing services.
I've tried using JavaScript to do this but it's was impossible to figure out my way around the retrieval of a specific note based on it's name so I'm using apple script :
on run {input, parameters}
(* https://www.macosxautomation.com/applescript/notes/02.html *)
(* https://apple.stackexchange.com/questions/271161/how-to-get-the-selected-text-into-an-applescript-without-copying-the-text-to-th *)
-- Back up clipboard contents:
set savedClipboard to the clipboard
-- Copy selected text to clipboard:
tell application "System Events" to keystroke "c" using {command down}
delay 1 -- Without this, the clipboard may have stale data.
-- remove formmating of the selected text that was copied onto the clipboard
-- and set it to a temp var called noteHTMLText whice later be
-- concatnted onto the body of the note
set noteHTMLText to "pre style=\"font-family:Helvetica,sans-serif;\"" & ¬
(the clipboard as Unicode text) & "/pre"
-- Restore clipboard:
set the clipboard to savedClipboard
tell application "Notes"
tell account "iCloud"
tell folder "Notes"
set currentBody to get body of note "WIDK"
set body of note "WIDK" to currentBody & noteHTMLText
end tell
end tell
end tell
beep 2 --https://stackoverflow.com/questions/21503589/play-a-sound-when-applescript-is-done
return input
end run
Thank you for the help,
Daniel
Post marked as unsolved
109
Views
I'm having issues with executing AppleScript from the application helper bundle, which is contained in my main application bundle.
I have a simple helper application bundle which only loads my script located in helpers' bundle Resources using NSAppleScript API and executes it. Script is really simple, it basically just deletes some other application bundle. I've tested the script as standalone and everything works fine. When I run the helper bundle everything falls apart. I'm getting -1743 error (Not authorised to send Apple Events to Finder). My helper bundle is not sandboxed, has enabled apple events in the entitlements file and I've added NSAppleEventsUsageDescription key to the plist. If I run this from Xcode it works, same if I execute the binary contained in the bundle from command line.
Any ideas what might be causing the issue?
Post marked as unsolved
102
Views
I have an applescript application created in Script Editor on macOSS 10.14.6 - it is save as a run time only application and iss signed with hardened runtime.
I have the following keys in my plist:
NSAppleEventsUsageDescription com.apple.security.automation.apple-events
I was having issues running the applescript application and it was suggested that I run "tccutil reset ALL" in terminal. This removed all my apps from Security &amp; Privacy/Privacy/Automation tab. Great.
But now when I run the app I always get the Not Authorized to send Apple events to Finder. I never get prompted to allow access.
How can I reset set it so asks for permissions?
Post marked as unsolved
60
Views
Hello there!
I need to help to optimize my apple script.
I need to import some contacts to Address book, and multiply delete by group name
I find solution to import from csv and delete contacts by one, but it so slow.
Maybe I can simulate open vcard, agree to import in Contacts app and then select all contacts in Contacts app like ctrl+A press delete and agree with delete?
Post marked as solved
55
Views
I have a column in apple numbers and each cell have different values like "1 oz" or "1/2 part". How can I remove the text and keep only the number part of the text? So "1 oz" would become only "1" or "1/2 part" whould be only "1/2"?
Post marked as unsolved
98
Views
Hello!
I am trying to make a script that will show a dialog box and at the same time loop through some code. I cannot find a way to do this, does anybody know how? Below is sort of how I want the code to work.
Thanks!
applescript
set thedialog to display dialog "A dialog box"
repeat while thedialog = true
set TimeUntilButtonPress to TimeUntilButtonPress + 1
delay 1
end repeat-This is incorrect, its just an example of how I want the code to work
Post marked as unsolved
1.1k
Views
Anyone had issues with running scripts on Big Sur? I get a command not found error and I’m guessing its a toggle or a command or a back age that needs to be added to enable it or its blocked by default for security reasons?
Post marked as unsolved
70
Views
Hello,
I have a Programm with the function to create folders
So you can check if you need this or that folder.
And to use that I used properties with bindings like:
AppleScript
property checkbox : true
Now when the checkbox in Xcode is bounded to checkbox I can see that the checkbox is off. But when I check the checkbox the Programm don't recognize it. And don't make a folder.
Applescript
if checkbox is true then
make new folder at desktop with properties {name:"My Files"}
end if
Thanks for your support! 💻/
Post marked as unsolved
84
Views
Hi I have this applescript working on BigSur Mac. Basically it makes me choose an image file from the file open dialog box and then copies the image's dimensions/file name into the Mac's clipboard (html format).
I want this functionality on an image file that is dropped on the applescript app's icon. Can anyone please help me write the droppeditem applescript that works in BigSur? Thanks!
Working code:
====
set this_file to (choose file) as «class furl»
try
tell application "Image Events"
launch
set this_image to open this_file
copy the dimensions of this_image to {H_res, V_res}
copy the name of this_image to originalname
close this_image
end tell
set myvar to originalname
set the clipboard to "src=\"" & myvar & "\"" & " width=\"" & H_res & "\"" & " width=\"" & V_res & "\""
end try
====
Post marked as solved
76
Views
Hello,
This is my code:
AppleScript
on startButton_(sender)
set folderDestination to choose folder
log folderDestination
log nameOfFolder
tell application "Finder"
make new folder at folderDestination with properties {name:nameOfFolder}
end tell
end startButton_
The idea ist to make a folder at the folder Destination (folderDestination) with the name of the folder (nameOfFolder).
This is the error from the console:
language
2021-03-13 09:28:02.844240+0100 Folder Creator[1571:39314] *** -[AppDelegate startButton:]: Finder got an error: Can’t make «class ocid» id «data optr0000000059FEE7F626C77C59» into type Unicode text. (error -1700)
But the log from the folder Destination and name did work:
language
2021-03-13 09:28:02.750713+0100 Media Folder Creator[1571:39314] file:///Users/name/Desktop/
and:
language
2021-03-13 09:28:02.753207+0100 Media Folder Creator[1571:39314] folderName123
The textfield in Xcode is connected to nameOfFolder.
Model Key Path: nameOfFolder
I do not know where the error is.
Thanks for your help.
Post marked as solved
77
Views
Hi,
I have a Problem. Really... ☺️
Is there a way to change the value of a property that you can see the new value in a Label?
This works:
AppleScript
property myValue : "Yes"
set myValue to "No"
log myValue
But when I bind myValue to a Label in my project, I can only see "Yes" in the Label.
Post marked as solved
97
Views
I've created an AppleScript to change the file creation dates for several hundred scanned images so that the dates reflect the actual date the photo was taken and not the date the image was scanned.
The script is as follows:
tell application "Finder"
set selectedFiles to (get selection)
repeat with i from 1 to count of selectedFiles
set thisFile to item i of selectedFiles
set thisName to name of thisFile
set yy to first word of thisName
set newDate to yy & "01010101.01"
do shell script "touch -t " & newDate & " " & quoted form of POSIX path of thisName
end repeat
end tell
When I run the script against one test file, I get the following: error "Finder got an error: touch: /1953 front of house.jpg: Read-only file system" number 1
Apparently the shell script is failing because the file is considered read only. I haven't tried it but I'm assuming the shell command would also fail from a terminal session.
The folder and file permissions are set to read/write so I can't figure out why the script is failing or develop a workaround.
Any advice would be greatly appreciated.
Post marked as unsolved
93
Views
Many valuable, valid AppleScript terms (e.g., "AXRaise") are not documented in the AppleScript command, statement, value, handler, event, object, keyword, and class references, etc., that are published on developer.apple.com (e.g., at https://developer.apple.com/library/archive/documentation/AppleScript/Conceptual/AppleScriptLangGuide/introduction/ASLR_intro.html#//apple_ref/doc/uid/TP40000983).
Has Apple (or anyone else) ever compiled a complete, comprehensive dictionary or list of all of the terms that are available and valid for use within AppleScript?