Automator / AppleScript help?

Discussion in 'macOS High Sierra (10.13)' started by cutter74, Apr 1, 2018.

  1. cutter74 macrumors member

    Joined:
    Nov 15, 2012
    #1
    I'm trying to create an automator workflow that will continuously monitor my "Downloads" folder and upon detection of a certain file type extension (.pdf), will move that file to subfolder "Adobe".

    I create and customise the workflow with the "Filter Finder Items" and "Move Finder Items" actions, but I am missing the AppleScript code that will wait until the file has completed downloading in order for Automator to use it in the correct destination folder.

    Can someone please help me with the AppleScript code and also let me know if it's necessary for the Automator Workflow to be saved inside the "Downloads" folder or can be saved anywhere I want?

    Thanks for your time.
     
  2. chabig macrumors 603

    Joined:
    Sep 6, 2002
    #2
    I’m not at my Mac, so these steps might not be exactly right. Right click on your Downloads folder and choose “Folder Actions”. When you enable folder actions, it does exactly what you want. The system monitors specific folders and when it sees a triggering event, like the appearance of a pdf file, it will run an AppleScript of your choosing. Search Mac help for Folder Actions for more information. The web is also full of help if you search for it.
     
  3. cutter74 thread starter macrumors member

    Joined:
    Nov 15, 2012
    #3
    I've already done enabled the folder actions and tied the workflow to the Downloads folder. I have also searched the web and tried the following code but it won't work.

    on run {input, parameters}

    if input is {} then

    return {}

    end if



    repeat

    delay 1

    set {size:fileSize, busy status:Busy} to (info for (input as alias))

    if not Busy and (fileSize is greater than 0) then return input

    end repeat

    end run
     
  4. chabig, Apr 1, 2018
    Last edited: Apr 1, 2018

    chabig macrumors 603

    Joined:
    Sep 6, 2002
    #4
    I think you’re making it too hard. Folder Actions will monitor the download folder for you. Use the Automator app to move the file. It is super easy.

    [​IMG]
     
  5. cutter74 thread starter macrumors member

    Joined:
    Nov 15, 2012
    #5
    chabig, thank you but I already have these parts.

    What I am trying to explain is that I need some sort of code or action that will instruct Automator to wait until the file has completed downloading. This code should go in between of the two actions you mention, otherwise Automator unfortunately grabs the file before it completes downloading, and the file never gets to the target directory.
     
  6. chabig macrumors 603

    Joined:
    Sep 6, 2002
    #6
    That first filter should capture the pdf after it’s done downloading. It’s not a pdf until the download is complete.

    I’ll try it on my Mac later.
     
  7. cutter74 thread starter macrumors member

    Joined:
    Nov 15, 2012
    #7
    Turns out, if I change the first filter from File Extension "is" to File Extension "contains", the two actions are enough by themselves! Thx for your help, chabig
     
  8. chabig macrumors 603

    Joined:
    Sep 6, 2002

Share This Page