Apple Script to automatically apply automator folder action workflows

Hello
     I'm trying to get an applescript to automatically apply an automator folder action workflow to a folder..
     Getting applescript to apply a scpt file to a folder as a folder action is straight forward. However, it seems that scpt files are different than automator folder action workflows..
     Normally I would just script the folder action in apple script, but this is for someone that can handle automator, but not apple script coding. This whole scripting is to solve the issue of subdirectories being creating and then files or subfolders being created there after. So we need to try to get automator folder actions to propagate though..  easy enough with applescript..
Any help would be appreciated...

Here is the code that I needed to happen...  Maybe I just missed something in automator... but this applescript properly applies itself to subfolders, which then allows me to apply specific scripts based on folder names and locations. Also if the subfolders already exist.. the scirpt also is applied to those.
on adding folder items to this_folder
  createlist(this_folder)
end adding folder items to
on createlist(item_list)
          set ActionScript to " REMOVED FOR PUBLIC DISPLAY:ApplyScriptSubfolders.scpt"
          set the the_items to list folder item_list without invisibles
          set item_list to item_list as string
               repeat with i from 1 to number of items in the the_items
                 set the_item to item i of the the_items
                                   set the_item to (item_list & the_item) as alias
                                   set this_info to info for the_item
                                   if folder of this_info is true then
                          tell application "System Events"
                                                                      display dialog "Attching script to " & the_item as text  --
                                 attach action to folder (the_item as text) using ActionScript
                                                       end tell
                            my createlist(the_item)
                                   end if
               end repeat
end createlist
I appreciate your help.. if you now know what has to happen and have a shorter way of doing so, please do so..
Thank you again,

Similar Messages

  • Automator Folder Action

    I have an Automator Folder action attached to my Downloads folder which moves any .jpg file to another folder where I normally place my images. It works for a while (automatically moving the .jpg files whenever a file is placed in the Downloads folder) and then stops fopr no apparent reason. On occassion when I logoff and on or restart, the action will work for a limited time.
    I don't have much experience with Automator and even less with Applescript. Any help will be much appreciated.
    I use an iMac with OS X 10.9.2.
    Thanks.

    Sorry... this is not an answer to your problem. More like an addition to your question.
    How do you attach an Automator Workflow as a folder action?
    I've made a Workflow to copy all files from an iTunes' playlist to a USB device, I want it to automatically run whenever I plug in the USB device. I've left-clicked the icon for the USB device and then "attach folder action", but I don't see any script to run an Automator Workflow.

  • Using Automator Folder Actions

    I have an automator folder action that runs to take any pdf file dumped in to the folder, send to the printer and then delete it.
    How do I make this run on a server that I'm not logged in to (effectively as a service), so that if a pdf file is generated somewhere on the network (maybe even a PHP script on a web site hosted on this server) and copied to this folder it still auto prints to the network printer?

    I'm using a hot folder to import to Aperture as well, and also had the same problems when I try to configure it.
    I solve it by creating an action in Automator that will copy all the images from the memory card to a temp folder when a card is inserted in the card reader. At the end of the action all the files inside the temp folder are moved to the actual hot folder, as you said this is almost instant so works perfectly.
    So basicly the workaround is the following:
    Card inserted - Image capture starts and copy all the images to a temp folder - Images then move to Aperture's hot folder - Aperture gets all the images.

  • ITunes 10.5 breaks automator folder action

    Just like itunes10 did
    osx 10.6.8
    itunes 10.5
    automator folder action with itunes tasks no longer works after 10.5 update.
    Is it the version check again?

    Unfortunately, it seems that this is a cross-platform problem between iTunes 10.5 and all NAS disks. Shared libraries on network drives worked fine under 10.4.1, but now there is just an endless loading cycle with no error message or time-out. There is a bit more about it in this thread.
    Martin

  • Script works in Script Debugger, but not a folder action - can u help?

    Hi
    I have written the following script to run as as folder action and it works fine when running it through in debug mode in Script Debugger, but as a folder action nothing happens.
    I wonder if someone could have a look and spot what the problem is.
    Thanks
    Nick
    on adding folder items to this_folder after receiving added_items
    set convertPath to "Macintosh HD:opt:local:bin:ffmpeg"
    tell application "Finder"
    set inPath to this_folder as alias
    set outPath to this_folder as alias
    set filesToConvert to (name of every item of inPath whose name extension is "m4a")
    end tell
    repeat with i from 1 to count of filesToConvert
    set fileName to removeExtension(item i of filesToConvert)
    do shell script POSIX path of convertPath & " -i " & (quoted form of ((POSIX path of inPath) & item i of filesToConvert)) & " -f mp3 -ar 44100 -ab 192k -acodec libmp3lame " & (quoted form of (POSIX path of outPath)) & quoted form of (fileName & ".mp3") & " -mapmetadata " & (quoted form of ((POSIX path of inPath) & item i of filesToConvert)) & ":" & (quoted form of (POSIX path of outPath)) & quoted form of (fileName & ".mp3")
    end repeat
    end adding folder items to
    to removeExtension(fileToParse)
    #display dialog fileToParse
    set prevTIDs to text item delimiters of AppleScript
    set text item delimiters of AppleScript to "."
    return first text item of fileToParse
    set text item delimiters of AppleScript to prevTIDs
    end removeExtension

    mmh, well, it seems something is awry with the triggering. other folder action scripts seemed to work fine, but now are intermittent.
    i created the following simple script:
    on adding folder items to this_folder after receiving added_items
    display dialog "1"
    end adding folder items to
    sometimes it works, sometimes not.
    what could be going wrong?

  • Automator Folder Action Not Running

    I have created a simple automator folder action that helps me to keep my downloads folder organized.    I want to move various files with certain file exensions to specific folder.
    I am finding the process to be intermittantly successful.   Sometimes it works, sometimes it does not run.      I've looked in activity monitor but do not see the automator launcher process running.   I think that is why I am having issues.   At other times, when it does run,  the workflow hangs and I have to kill Automator Runner.
    Any ideas on helping me with automator folder actions?
    Thank you,
    Jerold

    What does Finder -> select folder -> Control-Click -> Services -> Folder Actions Setup say about your existing folder action?
    Are folder actions enabled in the setup window?
    Is your folder action attached to your folder?
    For diagnostics, create a very simple Automator folder action (such as "Ask for Confirmation"; it does not need to make sense, it just needs to be something that you can use to verify the folder action occurred), and attach that to any folder. If that works, build up to making your PDF action work.

  • How to set up Automator Folder Actions?

    I have set up and sucessfully tested a workflow which sends any file found in a particular folder to the "paperless" app, then moves all files to a different folder called "Archived attachments".
    HOWEVER as a folder action,  nothing happens when a file is put into the folder. The file just sits there in the folder.
    To create a folder action I opened  "new folder action" in Automator, then dragged and dropped the working workflow file into the workspace, then set "Folder Action recieves files and folders added to" the appropriate folder, let's call it "Attachments".
    Just to complicate things, the files are placed into the "Attachments" folder using an applescript that captures all pdf mail attachments. This applescript works succesfully.
    So, where could I be going wrong?
    The working workflow "Attachments.workflow" consists of:
    Get Specificed Finder Items
    Make Sequential
    Get Folder Contents
    Open Finder Items
    Get Folder Contwents
    Label Finder Items
    Get Folder Contents
    New Dated Folder
    The erronious Folder Action consists of:
    Run Workflow (Attachments)
    In folder actions setup:
    "Enable Folder Actions" is ticked
    "PDF Attachments" folder is ticked
    "Attachments_folder.workflow" script is on.

    I'm confused. You showed two Automator actions with the same name, one was a folder action one wasn't.
    Are you sure the correct Automator action (the one that is a folder action) is attached to the folder?
    If when the Folders Action setup window is opened and you select Articles_Folder.workflow and then edit script are you getting the right workflow?
    Assuming you do I would start off very simply. Try this:
    It will label green screen shot image files saved to the Desktop.
    See if this works for you.

  • Automator Folder Actions - Use filename as subject in email

    I regularly email .pdf atttachments to my head office. These are hand-written sales orders which are scanned in. The scanner software gives each file a sequential filename (eg. OrderNo_110612).
    I have set up a Folder Action in Automator to create a new email and send the file as an attachment when it is added to the folder.
    Get Selected Finder Items
    New Mail Message
    Send Outgoing Messages
    I would really like to add the filename to the subject of the email. Is there a script I can run within the 'Run Shell Script' action that will extract the filename and can then be used as a variable in the subject field? This would allow both myself and head office to easily find the email at a later date should the need arise.
    Any help would be gratefully received. I am not a programmer, although I understand the principle of variables etc..
    I am using OS X Lion 10.7.2
    Any help would be really gratefully received.
    Many thanks

    sorry, spaced.
    on run {input, parameters}
              tell application "System Events"
                        return name of first item of input
              end tell
    end run
    P.s. this only work for the first filename.  if you want the names of multiple attachments it needs to be revised a bit.

  • Automator Folder Actions Broken in SLS

    I may be the only person that wants to use Automator in Snow Leopard Server. However, I've found that Automator can be a great match with a server to automate tasks when shared files come in from other users.
    The problem I am having is that the Folder Actions Trigger does not work. I can setup the Folder Actions under the contextual menu but nothing fires.
    If I set this up the same way in Snow Leopard Desktop Version Folder Actions work as they should and triggers when a file is placed in the monitored folder.
    Please tell me I'm not the only person that wants to use automator and folder actions? Anyone else having trouble with Folder Actions/Automator in Snow Leopard Server?

    The update is only good for Mac's listed in this About the Performance update.
    DALE

  • Help with creating Automator Folder Action

    Hi
    I want to create a folder action to empty my Caches from my both System and User Library files. I want a little help in creating the workflow. I tried to create a workflow, but the problem is it was asking for the system password when I selected the Library cache folder from my System. How can I create a workflow and save it as a plugin for my everyday action...
    thanks in advance..

    HI,
    Not sure if Automator can do that but AppleScript might. Post here for help.
    (Applications/Utilities)
    http://discussions.apple.com/forum.jspa?forumID=724
    Carolyn

  • Applying a folder action to thousands of folders?

    I am pulling my hair out with this; I need to know the best way to do this. My client said he had "a thousand or so" eps files that he wanted bundled into specific groups, then duplicated as pdf, jpg, png and tif files, each group in its own subfolder with an excel file that lists each of the file names for each bundle. So, essentially, the structure would look something like this:
    Archive of Files (all of them)Bundles (ie., singles or multiples)Type of Bundles (ie, 5, 10, 25, 50, 100, 200)Groups and excel file (ie, "62697200376 - 62697200380")Filename Folder (ie, "62697200376", "62697200377", "62697200378", etc)
    filename.eps
    filename.tif
    filename.pdf
    filename.jpg
    filename.png
    Insane.
    Anyway, what he actually sent me was 99,997 files - not "a thousand or so". So now, thanks to applescripts and automator, I have managed to:
    - separate the archive of files into bundles
    - set up the types of bundles
    - Group the files (no excel file just yet, that'll be last)
    - run applescript to create a folder for each eps file and move that eps file into it's folder
    - have a working (and tested) workflow that will duplicate and convert each eps file to a pdf and save that pdf to the same folder.
    I also have folder actions that will duplicate the pdf files as tif, jpg, and png once the pdf file is saved.
    How can I attach these folder actions to these folders? Specifically the filename folders? I know that you're supposed to select each folder one at a time and then click on "Folder Actions Setup" to choose the actions, but there are nearly 100,000 folders that I need to get these three actions attached to before I can run the workflow. I don't think I will survive the eminent implosion that I will suffer if I have to attach these folder actions to each of the 99,997 folders one at a time (and I definitely wouldn't meet my deadline of having all this done).

    Thank you all for the replies.
    So, I know I'm doing something wrong, but I just can't seem to see it. In applescript editor, I have this (based on Camelot's script above):
    tell application "Finder"
        set theFolders to every folder of (choose folder) as alias list
    end tell
    tell application "System Events"
        repeat with eachFolder in theFolders
            try
                attach action to eachFolder using "/Library/Scripts/Folder Action Scripts/Image - Duplicate as PNG.scpt"
            end try
            try
                attach action to eachFolder using "/Library/Scripts/Folder Action Scripts/Image - Duplicate as JPG.scpt"
            end try
            try
                attach action to eachFolder using "/Library/Scripts/Folder Action Scripts/Image - Duplicate as TIFF.scpt"
            end try
        end repeat
    end tell
    First, I tried it without the try / end try but it kept telling me that it didn't understand the attach action message. After I added the try / end try, it goes through but the actions do not get attached and I get an error number -1708 like this:
    tell application "System Events"
        attach action to alias "[removed]:Bundles:5:first copy:62697200376 - 62697200380:UPC (A).62697200376:" using "/Library/Scripts/Folder Action Scripts/Image - Duplicate as PNG.scpt"
            --> error number -1708
        attach action to alias "[removed]:Bundles:5:first copy:62697200376 - 62697200380:UPC (A).62697200376:" using "/Library/Scripts/Folder Action Scripts/Image - Duplicate as JPG.scpt"
            --> error number -1708
        attach action to alias "[removed]:Bundles:5:first copy:62697200376 - 62697200380:UPC (A).62697200376:" using "/Library/Scripts/Folder Action Scripts/Image - Duplicate as TIFF.scpt"
            --> error number -1708
    The folder "First Copy" is a backup I made of some of the files; there are 200 folders in there, each containing 5 subfolders, and in the subfolder is the actual eps file. I figure if I can make something work on this small backup I can make it work on the actual folders / subfolders.

  • Removing BCC with Apple Script when automatically BCC myself is set in pref

    I have "Automatically Bcc myself" set in the Mail Composing preferences, which I like because I get a copy of email that I send. I also have an apple script that forwards messages to an email address. When I used this apple script on Tiger, the BCC option was never added (it might have been a bug with Mail in Tiger); however, now on Leopard, the BCC option is always added when I used the apple script.
    I've tried setting the BCC field to Null and Blank, but that doesn't seem to work. I suspect that the field is set upon send or the "make new" directive. Does anyone know a way to tell Mail to not Bcc automatically in an Apple Script?
    Here is the forward apple script program:
    (* Cf. http://www.macosxhints.com/article.php?story=20060219014940761 *)
    (* RS 31st July 2006 *)
    set theAuthority to "person AT here"
    tell application "Mail"
    set theMessages to the selection
    repeat with thisMessage in theMessages
    set newMessage to make new outgoing message at end of outgoing messages
    tell newMessage
    set visible to true (* comment out whole line to stop 'blinking' windows *)
    set content to thisMessage's source
    set subject to "Fwd: " & thisMessage's subject
    set bcc to null (* my attempt to set bcc to null or blank *)
    make new to recipient with properties {address:theAuthority}
    end tell
    send newMessage
    set read status of thisMessage to true
    set was forwarded of thisMessage to true
    set junk mail status of thisMessage to true
    end repeat
    end tell

    Thanks for that reply!
    After more google searching, I found this on http://www.macosxhints.com/article.php?story=20040425063255443
    One of the responses said that you can add the lines:
    delete bcc recipients
    delete cc recipients
    "in that order" to the new message tell and get rid of the recipients. I had tried the delete before, but I thought I had to get the recipients before I deleted them. I'm not a very good apple script person. Here is my final script
    (* Cf. http://www.macosxhints.com/article.php?story=20060219014940761 *)
    (* RS 31st July 2006 *)
    set theAuthority to "email address here"
    (* or your personal Knujon address *)
    tell application "Mail"
    set theMessages to the selection
    repeat with thisMessage in theMessages
    set newMessage to make new outgoing message at end of outgoing messages
    tell newMessage
    set visible to false (* comment out whole line to stop 'blinking' windows *)
    set content to thisMessage's source
    set subject to "Fwd: " & thisMessage's subject
    make new to recipient with properties {address:theAuthority}
    delete bcc recipients
    delete cc recipients
    end tell
    send newMessage
    set read status of thisMessage to true
    set was forwarded of thisMessage to true
    set junk mail status of thisMessage to true
    end repeat
    end tell

  • Automator folder action won't run entire folder contents

    Hi,
    Ok, I think I'm pretty well versed in Automator and getting things to work. But this is just escaping me.
    I've made a simple Photoshop Droplet (done this before). Open Automator, built a workflow for getting a folders contents and then opening the contents with the Droplet.
    Saved this as a folder action,...
    But when I drag multiple items to the folder, it only runs the very first item and stops,...
    If I drag one by one into the folder it will work fine,....
    I'm going to have to be dragging multiples all the time, it's a waste of time to do one by one,...
    I'm totally missing something here,.... please help!!
    I'd also like to move the contents of the folder, once the Droplet has run, to the trash
    But first I have to get this darn thing to run on the entire folders contents,.....
    Workflows I've tried:
    1 - Open finder Items (open in my Droplet) works one at a time
    2 - Get Specified Finder Items (point to my folder)
    Get Folder Contents
    Open finder Items (open in my Droplet) again, works one at a time
    Thanks!!
    Christopher

    Hi Curly, and a warm welcome to the forums!
    I don't know much about Automator, and this may be of no help, but...
    It's either just picking up/passing one variable, when it either needs an array of variables, or needs to loop back for the next one.

  • Apple Script won't create new folder

    Hi all,
    First of all, let me explain that in no particular way I am any good with applescript. I find it confusing at the best of times. I've got a bit of code that will check to see if a new folder is created in a specific location. If a new folder is created, then it will copy the name of the folder and create a new folder with the same name in a different place. The reason for this is that I separate my file types (I'm a photographer) and I keep my RAW files in one folder, my PSD files in another, my JPEGs in another and so on. The current code I have worked up until I installed Yosemite as well as Server on my mac mini. Here's the code:
    on adding folder items to this_folder after receiving added_items
         set p to POSIX file "/Volumes/Projects/1. Raw"
         try
              tell application "Finder"
                   repeat with item_ in added_items
                        if kind of item_ is "Folder" then --if its a folder then make another in Ra
                             make new folder at p with properties {name:item_}
                        end if
                   end repeat
              end tell
         on error
              display dialog "Error occurred"
              return
         end try
    end adding folder items to
    The action is set to the JPEG folder, where an application automatically adds a folder (for this example, I'll use "z. test").
    z. Test is detected in the JPEG folder, and then the folder is replicated across to the other separating folders ready for when any new files are added. Trouble is, the error occurred dialog box shows up. I have the appropriate permissions for the hard drives that the folders reside on, and are replicated to the subfolders too.
    Is there anyway of finding out what the error is that's occurring? Or am I missing something since upgrading to Yosemite/Server? Any help would be most appreciated!
    Ian
    Th

    Hi,
    You can't rename an item with an object (the item_  is an object of type alias), use the name of item_
    To know the error, use the parameter in on error block.
    Try this :
    on adding folder items to this_folder after receiving added_items
        try
            set p to "/Volumes/Projects/1. Raw" as POSIX file as alias
            tell application "Finder"
                repeat with item_ in added_items
                    if kind of item_ is "Folder" then --if its a folder then make another in Ra
                        set tName to name of item_
                        make new folder at p with properties {name:tName}
                    end if
                end repeat
            end tell
        on error err
            activate
            display dialog "Error occurred : " & err
        end try
    end adding folder items to

  • Automator Folder Action: File Name = Spotlight Comment?

    Hey guys,
    I'm trying to have automator add the original filename of a file as spotlight comment when it is added to a certain folder. I can only use the "Set Spotlight Comments for Finder Items" in folder actions to add a specified comment, but nothing else. Is it possible to grab the file name via applescript?
    The idea behind this is to preserve the original file names of all downloaded files before they get renamed.
    Thanks,
    V

    Thanks for your reply, I now have your action installed and it does get the filenames, but I still can't add them to the spotlight comment text box. Looks like I didn't think this through properly.

Maybe you are looking for

  • Ringtone Help DESPERATE!!!

    I just got my 4S today and I'm stunned to find out that the ringtone selection on the phone is horrible. I don't want my phone to sound like a duck or a train, or my grandmothers old phone. I have a ringtone(mp3) stored on my pc and can't figure out

  • ORA-00257:

    Hi Friends I am getting this error ORA-00257: archiver error. Connect internal only, until freed. , when there is more than 30gb space empty on my system . an early help is appriciated . its very critical situation for me i am using oracle 8i on wind

  • Result row does not hide value

    Hi all, I have some calculated key figures that are using formula variables to get dates to do calculations on. Since summing up date values does not lead to anything meaningful, I selected the 'Hide' value in the 'Calculate results as...' section. H

  • Frustration with adobe premiere pro 2.0 invalid registration

    if someone is able to help, please do. how do i get by this problem of having the program reject what is suppose to be a valid generic registration number.

  • Window menu is missing in DW CS5 Mac

    I need to open the behaviors panel and I can't get to it. My window menu is missing. I have no idea how long it has been missing - I never open new panels. But, now I need it! Help! Here is a screenshot, it should be bestween Site and Help. How can i