I’m hoping someone can assist me with an automation issue I’ve been working on for the photo software “Capture One 21“. I need a folder (the capture folder on my desktop) to be monitored, and whenever a new file is added to it, the program (Capture One) should trigger the Command+D keyboard shortcut to export the RAW file into a JPG file. The JPG file ends in an other folder after exported.
Unfortunately, I have no background in programming, so I spent many hours trying to create a script with the help of ChatGPT, but now I’m just going around in circles.
So, what I’m basically trying to achieve:
- I want Capture One to automatically execute the “Command+D” keyboard shortcut every time a new image appears in my tethered capture folder on my desktop called “Hochzeit Teather Ordner”.
What I’ve done so far:
-
Automator workflow:
- I’ve set up an Automator workflow that monitors the “Hochzeit Teather Ordner”.
- The workflow includes a shell script that checks for new files in the folder.
- When a change is detected, an AppleScript is supposed to send the “Command+D” keyboard shortcut to Capture One.
-
Shell script in Automator:
- The shell script saves a list of files in the folder and periodically checks for updates.
- If a new file is detected, it triggers the AppleScript to simulate the keyboard shortcut.
-
AppleScript for sending keystrokes:
- The AppleScript is intended to send the “Command+D” shortcut to Capture One whenever a new image is detected.
- Unfortunately, I keep encountering a syntax error: “end expected, but on found.”
- Despite several attempts to troubleshoot, this issue persists, and I can’t seem to get the script to work correctly.
Problems encountered:
- Syntax errors: Repeatedly encountering the “end expected, but on found” error in the AppleScript.
- Automation permissions: Ensuring that Automator and System Events have the necessary permissions to send keystrokes, but still running into issues.
- Script execution: Despite several revisions, the AppleScript fails to execute as expected.
What I need help with:
- Fixing the AppleScript syntax error and ensuring it works seamlessly with the Automator workflow.
- Any advice or alternative approaches to achieve the desired automation in Capture One 21.
- Clarification on any specific permissions or settings that might be affecting the workflow.
Current shell script:
#!/bin/bash
captureFolder="$1"tempFile="/tmp/current_files.txt"
Save initial file list
ls "$captureFolder" > "$tempFile"
New file monitoring loop
while true; dosleep 10 currentFiles=$(ls "$captureFolder")if ! diff <(echo "$currentFiles") "$tempFile" > /dev/null; thenosascript -e 'tell application "System Events" to keystroke "d" using {command down}'ls "$captureFolder" > "$tempFile"fidone
Current AppleScript:
on run {input, parameters} -- Pfad zum Capture One-Ordner
set captureFolderPath to POSIX path of (item 1 of input)
-- Helper function to retrieve the file names in the folder
-- on listFilesInFolder(folderPath)
-- set fileList to do shell script "ls " & quoted form of folderPath
-- return fileList
-- end listFilesInFolder
-- Save initial file list
set currentFiles to listFilesInFolder(captureFolderPath)
-- New file monitoring loop
repeat
delay 10 -- Warte 10 Sekunden
-- Get new file list
set newFiles to listFilesInFolder(captureFolderPath)
-- Check if the file list has changed
if currentFiles ≠ newFiles then
-- Wenn sich die Dateiliste geändert hat, sende Tastenkombination an Capture One
tell application "System Events"
tell process "Capture One 21" -- Ersetze "Capture One 21" durch die Version, die du verwendest
if exists window 1 then
keystroke "d" using {command down}
end if
end tell
end tell
-- Update the list of current files
set currentFiles to newFiles
end if
end repeat
return input
end run
Any guidance or suggestions would be greatly appreciated.
Christian Rückert is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
0