I've been using Apple Script below for gathering every title & url of opening tab from browser window.
It's been works fine for a few years but it's failed recently (maybe in last two weeks).
#!/usr/bin/env osascript -l JavaScript
// url.js
function run(arg) {
arg = arg.toString()
let browser = ''
switch(arg) {
case 'chrome':
browser = 'Google Chrome'
break;
case 'edge':
browser = "Microsoft Edge"
break;
default:
browser = 'Google Chrome'
break;
}
Application(browser).windows().forEach((window) => {
console.log('\n\n')
window.tabs().forEach((tab) => {
const url = tab.url()
const name = tab.name()
console.log(`${name}\t${url}`)
})
})
}
It's been works like below (imagine that you open https://example.com on edge)
$ url.js edge
example.com https://example.com
But I found it failed today.
$ url.js edge
execution error: Error: Error: Application isn't running. (-600)
of course I'm make sure Edge browser up and running. Same error for Chrome.
I keep my environments(os, browser etc) up-to-date but I don't know which updates affects here.
Any thoughts or helps are welcome.
Settings
MacBook Pro M2
Sonoma 14.2.1
Edge 122
Chrome 122
Automation & Scripting
RSS for tagLearn about scripting languages and automation frameworks available on the platform to automate repetitive tasks.
Post
Replies
Boosts
Views
Activity
I’ve searched all over, posted to Reddit and Discord and forums and…. I can’t seem to get an answer. I don’t understand why this is so difficult!! It has to be doable, isn’t it?
Hello - I have a lot of photos and videos that end up in my downloads folder from amusement park photographers and rides. The problem is that when I go to download a recent trip the amusement park website downloads everything all over again, and creates a lot of folder and files in a random sequence. So I have to go through each folder and find the "new" files that I want to add to the Photos app.
Could you please help me write a script that would search through the entire downloads folder, and copy all of the files that are of photo or video type, created on or after a specified date, into a new folder within the downloads folder? This is effectively just eliminating the subfolders that the website download process created.
From there I would go to the newly created folder and sort by created date to obtain the new photos I want to add to the Photos app.
Hi Community,
I'm in need of some assistance with an AppleScript that increments the due date of reminders in the Apple Reminders app by one day. The reminders are set with a due date but do not have a specific time associated with them; they are just set to occur at some point during the day.
The challenge I'm facing is that when I use AppleScript to add one day to the due date, the script is setting the new due date with a time of midnight. Since the original reminders do not have a time (just a date), I want the script to increment the date without adding a time.
Here is the script I'm currently using:
set myList to list "My List"
repeat with myReminder in reminders of myList
if (due date of myReminder is not missing value) then
set currentDueDate to due date of myReminder
set newDueDate to currentDueDate + (1 * days)
set due date of myReminder to newDueDate
end if
end repeat
end tell
I am looking for a way to preserve the 'date only' attribute of the reminder when adding a day, so it does not default to a time of 00:00.
Does anyone have experience with this, or can anyone provide guidance on how to accomplish this? I haven't found a way to specify 'no time' or 'all-day' in AppleScript for the Reminders app.
Any help or pointers would be greatly appreciated. Thank you in advance!
I made an application in Script Editor and it works as expected. But the app seems to be getting automatically deleted at random times. For example, I made it a few days ago, tested it successfully, then went back today to look for it and it was gone. Tested this multiple times.
I bit more detail about my process:
I wrote the app in Script editor, exported it as an Application with run-only checked and no code signing
after manipulating a few things (.plist file, .icns file), I then remove extended attributes and code-sign using terminal. I have an Apple developer account that I use to code-sign:
xattr -cr <path_to_app>
codesign -s <my_developer_account> <path_to_app_bundle>
then I copy the app into my Applications folder and test it successfully
a day or more later, the app is gone (and I haven't even opened it again)
Ventura 13.1, Mac Book Pro 2021
A TextEdit RTD or RTFD document will save various document properties that you access and edit by selecting:
File > Show Properties >
Is is possible to retrieve these properties on a currently open document via AppleScript and place them in the clipboard?
I am interested in storing some text in the Comments and later being able to copy it to the clipboard without having to manually open the properties window, selecting the text and copying it.
Hi!!
I tried posting about my issue on the macscripter forum, but haven't receieved any love there so I thought I would try giving it a go here. I'm trying to help automate my wife's business which uses mac and am having difficulty getting an applescript to trigger by mail rule. I am not an apple guy and myself use linux, so maybe i am overlooking something basic that I need to enable?
I gave the mail.app full disk access in the security panel. If I set a rule, like to move a message to another mail folder it executes without problems. However, I can't get any applescripts to run triggered by mail rule, even something very simple...like writing to the display or logging an event. I looked through the console and saw no error messages or any evidence even that the applescript tried to run. We are running the latest mac sonoma. I asked chatgpt for help trying to debug what was wrong but it ran out of suggestions for me as well. This problem is driving me crazy, I can't understand how a nice new mac computer I bought for my wife's business is failing at the most basic task... arrrgh. Any help greatly appreciated!!!
Hi,
I have an app generated by using osacompile on an applescript file. The app works fine as expected.
However, when I try to sign it, I get two errors as in the screen shot below:
After some googling around, I deleted the _CodeSignature folder in the .app directory but still signing fails with the same error.
So, I would like to know two things:
Is it possible to sign .app files created using osacompile as in my case?
If yes, what am I missing and how to resolve my situation.
Thanks,
Hey! Im new here and currently learning iOS/macOs development (SwiftUI), so...take me easy :) I want to create a simple macOS app to let user set time until computer power off. I found an example with AppleScript and use it on my app, but I found that App won't run with Sandbox enabled, and to deploy app on AppStore it show me that Sandbox must be enabled.
The script I want to use:
'tell application "System Events" to shut down'
I found some examples that add script onAbsolute path, but after I do that, it won't let me to distribute the app, only export to run local.
It is any way to make script running (no matter, if app ask for user permission/admin pass) ?
I am trying to automate a backup terminal script to mirror some directories to my NAS. The terminal script is working fine, so I want to automate them. The recommended path uses the launchctl agent, which, from the description, should be what I need. However, I have been running into two errors and looking for answers.
I am using a M1 Mac mini with 8GB of memory (for reference).
First, I get an error 23, which means too many files are open. If I reboot the machine, this error goes away. But why am I getting this message? I can run the script manually without a problem, and the system is running fine. The machine does little, so it should have almost nothing open.
The second error, once the 23 is cleared, is error 12, cannot allocate memory. The machine is an 8GB machine but is reporting 3GB free. Again, the script runs fine in the terminal.
I suspect the problem is the agent, but I am unsure how to diagnose or resolve these issues. I do not want to reboot the machine to run the backup, and so is the agent running under some system constraints that are too limiting. Can I change those limits for the job and make the recommended process to automate work?
Any suggestions would be appreciated.
Hi,
not sure if this forum is the right place to ask, but it’s extremely difficult to search the web for answers about shortcuts.app (must be the name…).
I’m learning python currently and I’m trying to automate recurring tasks on my Mac easily. I have a python script as a first test-case that works (It basically makes a bunch of named folders).
I use Apples Shortcuts.app to execute the python-file with the shell-script action. I start this script in Finder from the Quick Actions menu. The script creates my folders, but not in the selected folder when executing it, but always in my users home folder /Users/markus/.
I suspect I have to somehow tell the Shortcut to take the currently selected folder as a variable or something. I tried to read the help but I don’t find anything useful and don’t understand the options of the Shell-Script Action in Shortcuts.app.
Any ideas how I can get this to work? Or does anyone have a link to a good forum to ask questions about Shortcuts.app and automation?
Thanks!
Regards
Markus
How to create a UTF-8 encoded text file using do shell script?
As I understand it, the command should start with do shell script. And what to write next?