• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
"Wait for files to copy" and "Dispense disk items incrementally" actions - AS analogues and how to use?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

"Wait for files to copy" and "Dispense disk items incrementally" actions - AS analogues and how to use?


  • Subject: "Wait for files to copy" and "Dispense disk items incrementally" actions - AS analogues and how to use?
  • From: ILJA SHEBALIN <email@hidden>
  • Date: Sat, 22 Apr 2017 04:39:16 +0300

Hello,

It's now past 1.5 years as I'm trying to build a simple workflow in the form of a folder action: once photos of acceptable formats arrive in "Downloads" folder import them to iPhoto (using iLife '11 and am on 10.7.5 , "Lion"). Having learned much over this time span about AppleScript as well as Automator I returned to my unrefined workflow and now it has these actions:

  1. Folder action is attached to folder "Downloads"
  2. The actions:
    1. Set value of variable (stores references to photos arrived in "Downloads" folder). I named this variable "Photos downloaded"
    2. Get value of variable set in step 1. Parameters: receives no input, because passes it to the next action just for that action.
    3. Run AppleScript. The script determines (parses references, grabs extension's part of the reference, verifies if it's one of "jpg, jpeg") if the files are photos. If no the whole workflow halts, if yes, then proceeds further. The script's body's below:
      • on run {input, parameters}

        tell application "Finder"
        set theList to input
        set POSIXfiles to {}
        repeat with i from 1 to (count theList)
        set end of POSIXfiles to POSIX path of item i of theList
        end repeat
        POSIXfiles

        set FileExtensions to {}
        repeat with j from 1 to (count POSIXfiles)
        set TheItem to item j of POSIXfiles
        set AppleScript's text item delimiters to "/"
        set BaseName to text item -1 of TheItem
        set theDot to offset of "." in BaseName
        set MyExtension to text (theDot + 1) thru -1 of BaseName
        set end of FileExtensions to MyExtension
        end repeat
        FileExtensions


        ignoring case
        set AcceptableFormats to {"jpg", "jpeg"}
        end ignoring

        if some item of FileExtensions is not in AcceptableFormats then tell application "System Events" to set enabled of folder action "Downloads" to false
        end tell
        end run
    4. Get value of variable (the same value as in step 2), receives no input, passes references to the next action which is
    5. Import to iPhoto. Receives input from step 4. The new values on output of the current action are then stored in a new variable, hence
    6. Set value of variable. Receives input. Stores references to imported photos. I named this variable "Photos imported" 
    7. Get value of variable (the same value as in step 6), receives no input, stores references to imported photos only to pass it to the next action which is
    8. Run AppleScript. It acquires references from the previous action and transforms them into a set of filenames of the imported files, formatted as a textual list. The script's body:
      • on run {input, parameters}

        tell application "iPhoto"
        set PhotoNames to {}
        repeat with i from 1 to (count input)
        set end of PhotoNames to name of contents of item i of input
        end repeat
        PhotoNames
        set AppleScript's text item delimiters to return
        return PhotoNames as text
        end tell
        end run
    9. The formatted text was necessary to pass it to the last action Show Growl Notification (which Mountain Lion onwards with its Notification Center has built-in OS X analogue of named "Show Notification") to appear as annotation in the form of list of the filenames imported,  beneath the main text of the Growl's notification banner.

It works fine but only on one-file-at-a-time basis. I originally thought it out to let my photos from Android phone flow via bluetooth to Downloads and then this fold action would sping to life and the rest of the job. Unfrotunately it processes only the first file arrived but falls asleep just as it's done with it. After some time I discovered by accident the actions mentioned in the subject of this thread on macosautomation.com. I placed "Wait for files..." at the beginning to no avail. Then there was "Dispence items..incrementally". I placed "Loop" at the end of my folder action workflow and placed "Dispense" alternately before step 1, after step 2. For testing purposes I added "Get Specified Finder items" and added several jpg files of "Downloads" folder. I then deployed "Wait for files..." before step 1 rearranging the workflow a bit so that "Dispence" was right before "Import to iPhoto". This time it worked processing "incrementally" every item but did that only being trailed by "Get specified" action with target files consolidated in a single group. I feel that with these two actions that's where the shoe pinches but I'm not sure whether I can accomplish my goal in Automator (even if using AppleScript's injections),  and whether these actions can help.  

  1. So how are they supposed to work and in a what possible context? 
  2. How do I make my workflow to collect the photos being arrived one by one during a very short length of time, i.e., how do I make the folder action to trigger itself every time a group of photos come into a folder?
  3. What are AppleScript implementation of every of these two actions?
  4. Do these actions have a sense at all? 
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Prev by Date: Scripting the Touch Bar
  • Next by Date: Re: Applescript & RTF & TextEdit...
  • Previous by thread: Scripting the Touch Bar
  • Next by thread: Undead script lives whenever I launch my newsreader
  • Index(es):
    • Date
    • Thread