Tuesday, January 28, 2020
  • Index
  •  » Automator
  •  » Multiple "Run AppleScript" actions cause workflow to fail

#1 2019-12-28 03:39:36 pm

gcoghill
Member
Registered: 2006-03-10
Posts: 6

Multiple "Run AppleScript" actions cause workflow to fail

I am running into the following error in Automator when attempting to run multiple AppleScript actions, the 2nd and 3rd setting variables:

-[NSAppleEventDescriptor fileSystemRepresentation]: unrecognized selector sent to instance 0x6000009e51a0

As long as there is only one of the second or third "Run AppleScript" actions in the workflow (either one), it runs successfully. So it does not seem to be an issue with the content of either AppleScript.

The first AppleScript is merely to get an "Ask For Text" window to appear:

Applescript:

activate

The next AppleScript (first one to prompt to get a variable) is:

Applescript:

--
-- a sample AppleScript program to prompt a user to select an item from a list
--

-- display a dialog to prompt the user to select a dayname from a list
set myDay to {"m", "t", "w", "h", "f", "s", "x"}

-- get the file the user selected from the list
set selectedDay to item 1 of {choose from list myDay}

and the third one, again to set a variable:

Applescript:

set chosenTime to choose from list {"today", "yesterday"}

set UserChoice to item 1 of chosenTime
set myTime to "" -- good practice to initialise a variable
if UserChoice is "today" then
   set myTime to "0"
else if UserChoice is "yesterday" then
   set myTime to "1"
end if

I can run with AppleScript 1 and 2, or AppleScript 1 and 3, and no errors. But if I run with 1, 2 & 3 I get the error.

Here is the shell script in case that helps:

FILE_CONTENT=$1
DATE=$(date -v-$3d +"%Y-%m-%d")
echo -e "$DATE $2 | $FILE_CONTENT \n___\n" | cat - /Users/George/Dropbox/Notes/\|\•\ recap_test\ "$DATE".txt > /tmp/tempfile && mv /tmp/tempfile /Users/George/Dropbox/Notes/\|\•\ recap_test\ "$DATE".txt
echo -e "$DATE $2 | $FILE_CONTENT \n___\n" | cat - /Users/George/Dropbox/Notes/\|\•\ 1journal_test\.txt > /tmp/tempfile && mv /tmp/tempfile /Users/George/Dropbox/Notes/\|\•\ 1journal_test\.txt

Ultimately, I am trying to modify the date variable in the shell script using the variable from the 3rd AppleScript (the idea being to subtract the value in the variable from the 3rd AppleScript).

Last edited by gcoghill (2019-12-28 03:41:42 pm)

Offline

 
  • Index
  •  » Automator
  •  » Multiple "Run AppleScript" actions cause workflow to fail

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)