Trying to use AppleScript, and I am getting an error

Helo,

I am trying out Retrobatch Version 2.0.1 (1379), to see if I can automate photo changes.

When I try this AppleScript…

tell application "Retrobatch"
	set d to open ((POSIX file "/Users/jim/Desktop/BaseWorkflow.retrobatch") as alias)
	tell d
		execute (execute input items "/Users/jim/Desktop/" output folder "/Users/jim/Desktop/")
	end tell
end tell

…it works, but I get this error in the Script Editor:

error “Retrobatch got an error: Can’t get document "BaseWorkflow.retrobatch".” number -1728 from document “BaseWorkflow.retrobatch”

What is wrong with my AppleScript code?

•••

Second question: is there a way to have the above only work with files that are selected in the Finder?

Third question: is there a way to have Retrobatch quit after the last file is converted?

Hello @Magic , welcome.

Are you using the App Store version of Retrobatch? That error means that Retrobatch doesn’t have permission to open up the workflow for reading. If you give Retrobatch “Full Disk” permissions under System Settings ▸ Privacy & Security ▸ Full Disk Access, the AppleScript should start working.

For question #2, if you’re using the version of RB off our website, there’s a “Get Selected Finder Images” node which should do what you’re after.

For question #3, there’s a “Quit Retrobatch” node.

However, if we step back a little bit, I think what you should probably do is write a quick Shortcut for what you’re after. Here’s a quick one I made:

It references a workflow that inverts images, writes it to a folder, and then has the Quit node at the end of the chain. I also have the “Use as Quick Action” option selected in the shortcut, so it shows up in the Finder. So I can select images in the Finder, right click and choose “Quick Actions ▸ Invert Write and Quit in Retrobatch” and everything just comes together as you’d like.

1 Like

No, I am using the download from your website.

I tried using the “Get Selected Finder Images” node. Crashed twice. I sent in crash reports.

“Quit Retrobatch” node works well. Thanks!

I tried using a shortcut based on your screenshot, but I am getting this error:

Any troubleshooting suggestions?

Thanks for sending in the crash reports, I’ll take a look at them.

I’m wondering if anything is printing out in the Console app when you run this. Console is located in your /Applications/Utilities/ folder, and it’s got a ton of messages that come out through it. But if you do a search for “retrobatch” and then run the Shortcut - hopefully something will come up with more info.

I’m guessing that there are no errors from Retrobatch when you run it?

1 Like

Hi Gus,

You’re welcome, and thanks!

Which report in Console should I be searching for? (I’m a newbie when it comes to the Console app)

Correct. If I run it from Retrobatch, zero errors.

I do see a crash log when I try to add the “Get Selected Finder Images” node:


Translated Report (Full Report Below)

Process: Retrobatch [5964]
Path: /Applications/Retrobatch.app/Contents/MacOS/Retrobatch
Identifier: com.flyingmeat.Retrobatch
Version: 2.0.1 (1379)
Code Type: X86-64 (Native)
Parent Process: launchd [1]
User ID: 501

Date/Time: 2023-11-10 12:26:10.2612 -0800
OS Version: macOS 14.1.1 (23B81)
Report Version: 12
Bridge OS Version: 8.1 (21P1069)
Anonymous UUID: 116D2673-5C66-0CF0-98AA-071B7AFBA750

Time Awake Since Boot: 14000 seconds

System Integrity Protection: enabled

Crashed Thread: 3 Dispatch queue: com.apple.root.default-qos

Exception Type: EXC_BAD_INSTRUCTION (SIGILL)
Exception Codes: 0x0000000000000001, 0x0000000000000000

Termination Reason: Namespace SIGNAL, Code 4 Illegal instruction: 4
Terminating Process: exc handler [5964]

Thread 0:: Dispatch queue: com.apple.main-thread
0 libsystem_kernel.dylib 0x7ff805112a6e mach_msg2_trap + 10
1 libsystem_kernel.dylib 0x7ff805120e7a mach_msg2_internal + 84
2 libsystem_kernel.dylib 0x7ff805119b92 mach_msg_overwrite + 653
3 libsystem_kernel.dylib 0x7ff805112d5f mach_msg + 19
4 CoreFoundation 0x7ff80522d405 __CFRunLoopServiceMachPort + 143
5 CoreFoundation 0x7ff80522be75 __CFRunLoopRun + 1371
6 CoreFoundation 0x7ff80522b352 CFRunLoopRunSpecific + 557
7 HIToolbox 0x7ff80facd9d9 RunCurrentEventLoopInMode + 292
8 HIToolbox 0x7ff80facd7e6 ReceiveNextEventCommon + 665
9 HIToolbox 0x7ff80facd531 _BlockUntilNextEventMatchingListInModeWithFilter + 66
10 AppKit 0x7ff80883b885 _DPSNextEvent + 880
11 AppKit 0x7ff80912f348 -[NSApplication(NSEventRouting) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1304
12 AppKit 0x7ff80882cdfa -[NSApplication run] + 603
13 AppKit 0x7ff808800e10 NSApplicationMain + 816
14 dyld 0x7ff804dc93a6 start + 1942

Thread 1:: com.apple.NSEventThread
0 libsystem_kernel.dylib 0x7ff805112a6e mach_msg2_trap + 10
1 libsystem_kernel.dylib 0x7ff805120e7a mach_msg2_internal + 84
2 libsystem_kernel.dylib 0x7ff805119b92 mach_msg_overwrite + 653
3 libsystem_kernel.dylib 0x7ff805112d5f mach_msg + 19
4 CoreFoundation 0x7ff80522d405 __CFRunLoopServiceMachPort + 143
5 CoreFoundation 0x7ff80522be75 __CFRunLoopRun + 1371
6 CoreFoundation 0x7ff80522b352 CFRunLoopRunSpecific + 557
7 AppKit 0x7ff808998a00 _NSEventThread + 122
8 libsystem_pthread.dylib 0x7ff805152202 _pthread_start + 99
9 libsystem_pthread.dylib 0x7ff80514dbab thread_start + 15

Thread 2:
0 libsystem_pthread.dylib 0x7ff80514db88 start_wqthread + 0

Thread 3 Crashed:: Dispatch queue: com.apple.root.default-qos
0 Retrobatch 0x108c0d1a1 specialized OTGetSelectedFinderImages.getFinderURLs() + 1233
1 Retrobatch 0x108c0c67b OTGetSelectedFinderImages.preflightInputs(:slight_smile: + 91
2 Retrobatch 0x108c0c91f @objc OTGetSelectedFinderImages.preflightInputs(
:slight_smile: + 47
3 Retrobatch 0x108c03299 __29-[OTWorkflowRunner preflight]_block_invoke + 478
4 libdispatch.dylib 0x7ff804fa92e6 _dispatch_call_block_and_release + 12
5 libdispatch.dylib 0x7ff804faa59a _dispatch_client_callout + 8
6 libdispatch.dylib 0x7ff804facdba _dispatch_queue_override_invoke + 977
7 libdispatch.dylib 0x7ff804fb9776 _dispatch_root_queue_drain + 328
8 libdispatch.dylib 0x7ff804fb9f22 _dispatch_worker_thread2 + 152
9 libsystem_pthread.dylib 0x7ff80514ec06 _pthread_wqthread + 262
10 libsystem_pthread.dylib 0x7ff80514db97 start_wqthread + 15

Thread 4:
0 libsystem_pthread.dylib 0x7ff80514db88 start_wqthread + 0

Thread 5:
0 libsystem_pthread.dylib 0x7ff80514db88 start_wqthread + 0

Thread 3 crashed with X86 Thread State (64-bit):
rax: 0x0000000000000000 rbx: 0x00006000028fb2d0 rcx: 0x00000000dae1f005 rdx: 0x0000000000000032
rdi: 0x0000000000000000 rsi: 0x00000000000027d0 rbp: 0x0000700009b65aa0 rsp: 0x0000700009b658a0
r8: 0x000000000000004d r9: 0x00000000db01f832 r10: 0x000000000000003f r11: 0x0000000000000005
r12: 0x00007ff8480959c0 r13: 0x00007ff847b7e680 r14: 0x0000700009b659a0 r15: 0x00006000028fb420
rip: 0x0000000108c0d1a1 rfl: 0x0000000000010246 cr2: 0x0000000000000000

Logical CPU: 2
Error Code: 0x00000000
Trap Number: 6

Thread 3 instruction stream:
89 45 d0 e9 44 ff ff ff-48 8b 05 48 15 2d 00 48 .E…D…H…H.-.H
89 45 d0 48 89 df 48 8b-b5 38 ff ff ff 48 8b 85 .E.H…H…8…H…
30 ff ff ff ff 50 08 48-8b 1d 19 20 2d 00 48 8b 0…P.H… -.H.
bd 48 ff ff ff ff d3 48-8b bd 40 ff ff ff ff d3 .H…H…@…
48 8b bd 50 ff ff ff ff-d3 48 8b 45 d0 48 8d 65 H…P…H.E.H.e
d8 5b 41 5c 41 5d 41 5e-41 5f 5d c3 0f 0b 0f 0b .[A\A]A^A_]…
[0f]0b 0f 0b 66 66 2e 0f-1f 84 00 00 00 00 00 53 …ff…S <==
48 8b 06 48 85 c0 75 16-48 89 f3 48 8b 3a e8 48 H…H…u.H…H.:.H
9e 1e 00 48 89 c7 e8 90-a2 1e 00 48 89 03 31 d2 …H…H…1.
5b c3 66 2e 0f 1f 84 00-00 00 00 00 0f 1f 00 55 [.f…U
48 89 e5 41 56 53 48 8b-05 22 75 37 00 4c 8b 34 H…AVSH…"u7.L.4
07 48 8b 5c 07 08 48 89-df e8 fd a1 1e 00 4c 89 .H...H…L.

(trimmed, as the forum won’t let me post it all)

Thanks for that report! It’ll be super helpful.

In Console, there should be the name of your computer in the top section called “Devices”. Select that and hit the “Start Streaming” button that’ll come up.

It’s not a huge deal, as I think I know what might be going on based on the crash report. I hope to have a new build for you to try out soon.

-gus

1 Like

I am not sure if I did this right, but I hope that this helps:

default 19:13:45.950639-0800 Console Unable to find object to handle service <_NSServiceEntry - 0x600002f20f00:

bundleIdentifier: (null)

<… snipped by Gus …>

(continued below)

<… snipped by Gus …>

Thanks for that!

I’ve just made some changes and uploaded a new build to the latest builds page:
https://flyingmeat.com/download/latest/#retrobatch

When you get a chance, can you try it out and let me know if it still crashes for you?

thanks,

-gus

1 Like

Thanks Gus!

Some good news—when running Version 2.0.2 (1392), the addition of the “Get Selected Finder Images” node no longer causes a crash.

The first time I ran the batch I got this:

However, if I trigger the batch with a Shortcut, I get this:

Screenshot 2023-11-13 at 4.01.38 PM

It does appear to complete.

Thoughts?

Separate—when you release version 2.0.2, will my current Version 2.0.2 (1392) update? Or will I have to manually download the release version?

So Shortcuts runs the workflow successfully, but reports an error. Does Retrobatch crash or quit or anything when the workflow is run?

You’ll be updated to the final release. Unless you got RB via the App Store; you’ll need to delete it and then re-download it from the store in that case (I’m guessing that’s not what you’ve done though?)

1 Like

No crash that I can detect.

I think that “Quit Retrobatch” node is the cause of the error.

I was using the “Quit Retrobatch” node at the end, as the AppleScript needed it.

To test the issue using Shortcuts, I deleted the “Quit Retrobatch” node, and now Shortcuts does not report an error.

So, my conclusion is that there is a bug when using the “Quit Retrobatch” node, when using Shortcuts to run a batch.

Correct. I am using the version from your website.

Happy to hear that the update will happen automatically.

Thanks Gus!

OK. That makes sense then. RB is quitting before it can respond to the Shortcut action. I’ll find some way to make this better.

-gus

1 Like

I’ve got this working correctly now in the latest builds:
https://flyingmeat.com/download/latest/#retrobatch

Shortcuts should no longer report an error when running a workflow w/ a quit node in it. And let me know if it still happens to you!

-gus

Version 2.0.2 (1409) fixes it.

Thanks Gus!