Hi all,
New to the community—I’m an IT geek and photographer but fairly new to Apple scripting technologies. I’m comfortable with programming, but my training is ancient, and have only a basic understanding of current languages.
I modified this script to automatically add photos exported from Lightroom into Apple Photos. I’d like to do something similar to import images into a social media client.
- The best client I’ve found for this is Statuz, since most aren’t scriptable or don’t support “open in” with image files from the OS.
- Statuz supports open single files rather than a list of files as in the Photos script.
- My script to works if I prompt for a folder as input, then loop through the contained files.
- My script fails with a folder action as input, both treating the input as a folder and as a list of files.
My script seems to be failing because receiving input from a folder action creates a different data type than prompting for a folder. Is there a way in Automator or Script Editor that I can view the types and contents of variables as I step through a script?
For reference, this is the AppleScript portion of my working Automator script:
on run {input, parameters}
tell application id "com.apple.photos"
set thisAlbum to album "Lightroom imports" of folder "Social media"
try
if input is not {} then
import input into thisAlbum with skip check duplicates
end if
on error errorMessage
display alert "IMPORT ERROR" message errorMessage
end try
end tell
return input
end run
This script to select a folder and open images in Statuz works as is but not if I take out the folder prompt and use the input from the folder action.
on run {input, parameters}
set input to choose folder with prompt "Please select folder"
tell application "Finder"
set filesToOpen to the files of input
repeat with currentFile in filesToOpen
tell application "Statuz"
open currentFile
end tell
end repeat
end tell
return input
end run
This script treating input from a folder action as a list never runs the repeat loop. (Dialog steps added for debugging.)
on run {input, parameters}
display dialog "script 1" & return
tell application "Finder"
set filesToOpen to input
display dialog "script 2" & return
repeat with currentFile in input
display dialog "File: " & currentFile & return
tell application "Statuz"
open currentFile
end tell
end repeat
end tell
return filesToOpen
end run