Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Getting A Variable Into AppleScript With Automator

User uploaded fileUser uploaded file


Then the following AppleScript runs:


property parentFolder : (path to desktop folder)

on run argv

  set myList to item 1 of argv
  set myFile to myList's item 1
  set myMonth to month of (current date)

  set currentMonthFolder to myMonth & space & "Announcements" as string


  tell application "Finder"
  if not (exists folder currentMonthFolder of parentFolder) is true then
       make new folder at parentFolder with properties {name:currentMonthFolder}
  end if

  move myFile to folder currentMonthFolder of parentFolder

  end tell
end run



But when running the script does not work as intended. The variable myFile is not getting what it should, so I would like to pass the variable from the previous automator action and do it that way.


This is supposed to take a file named 'ANNOUNCEMENTS_' then add the date and move it to the corresponding announcements folder.

OS X Yosemite (10.10.2), null

Posted on Mar 16, 2015 6:02 AM

Reply
5 replies

Mar 16, 2015 7:06 AM in response to techteej


But when running the script does not work as intended. The variable myFile is not getting what it should, so I would like to pass the variable from the previous automator action and do it that way.



I tested through the setting of myFile and it is setting the variable, so it looks like that's not the problem:


User uploaded file


Try selecting "ignore this actions input" in the "get value of variable" action (under [options]) that precedes the run applescript (possibly to much is being passed to applescript)

Mar 16, 2015 7:23 AM in response to techteej

Review the order of the solution that I originally provided you about a week ago.


You have written a different workflow than my previous solution, and therefore, argv receives only one argument, the renamed filename itself. Here is a revised workflow that puts the renamed file into the proper March Announcements folder on the desktop. You may want to consider a no-whitespace date string as part of the filename, but that is only a suggestion.


User uploaded file

User uploaded file

User uploaded file

Apr 27, 2015 6:14 AM in response to techteej

The examples that I have provided are Automator applications, and not folder actions. Changing the Parent folder property (providing it exists on local disk, and that you use proper AppleScript to describe its path) should not have any bearing on the outcome of this application.


In the Automator window, turn on show results where you think it is not working, and enable the log at the bottom of Automator so you can see any red text that signifies an error has occurred.

Getting A Variable Into AppleScript With Automator

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.