Customize Folder Action and Email script

I have been adapting the below script so if I drop a file on the script, the file will be emaild to the default address. But, I can't figure out how to customize the two below easy tasks into this script. Thanks for any help out there!
1. A file is moved into folder1 triggers the script.
2. After the file is email'd I would like it to be moved into folder 2. I have found a script in this forum that moves the file, but I don't know where to add it.
on adding folder items to theFolder after receiving theAddedItems
tell application "Finder"
move theAddedItems to folder "G5:Users:camille:Desktop:folder2:"
end tell
end adding folder items to
The Send File Script that I have been adapting (concept and initial coding by Paul Van Cotthem):
property this_folder : "G5:Users:camille:Desktop:folder1"
property emailAddress : "[email protected]"
global sendAction
on open fileList
-- If one prefers to test for folders before the files are created, the enable this code.
repeat with filePath in fileList
if (filePath as string) ends with ":" then
display dialog "Please drop only files, not folder." buttons {"OK"} default button 1 with icon 0
return
end if
end repeat
enterAddress()
repeat with filePath in fileList
set filePath to filePath as string
if filePath does not end with ":" then -- it's a file
tell application "Finder" to set fileName to name of item filePath
tell application "Microsoft Entourage"
-- This code is faster, but if the user trashed the attached files before sending them, Entourage cannot send the attachtments.
make new outgoing message at out box folder with properties {recipient:emailAddress, subject:fileName, attachment:filePath}
-- This code is slower, but attached files are saved into Entourage's message database immediately.
set theSubject to "File attached: " & fileName
set newmsg to make new draft window with properties ¬
{recipient:{address:emailAddress, recipient type:to recipient}, subject:theSubject, content:theSubject, attachment:filePath}
send newmsg
end tell -- Entourage
end if -- file or folder?
end repeat -- filePath
end open
on run
enterAddress()
end run
on enterAddress()
display dialog "Send to:" buttons {"Cancel", "Send now"} with icon note ¬
default button 2 default answer emailAddress giving up after 2
set dialogResult to result
set sendAction to button returned of dialogResult
set emailAddress to text returned of dialogResult
end enterAddress
G5   Mac OS X (10.3.9)  
G5   Mac OS X (10.3.9)  
G5   Mac OS X (10.3.9)  
G5   Mac OS X (10.3.9)  

Go ahead and put that chunk of code on a new line at the very bottom of your script. Then between the on adding folder items to theFolder after receiving theAddedItems line and the tell application "Finder" line, insert the word open on a line by itself.
By putting the term "open" there you are telling the script to run all the code in the "on open" block when triggered by the folder action handler. To make the folder action active you'll need to save the droplet in your ~/Library/Scripts/Folder Action Scripts folder, and then you'll need to attach it to something by control-clicking the desired folder and/or using the Folder Action Setup Utility to connect script to folder.

Similar Messages

  • Render and Email script

    Hello everybody. I have a question that I have thoroughly researched on the web with no results.
    I am trying to get the default After Effects "Render and Email" script to run properly. I have only been able to successfully send FROM one specific email address TO another (slightly less specific) email address. Most other email services I put in (icloud, gmail, etc) all give strange errors upon execution.
    For the SENDING email address, I'm currently using one I created that is a part of my web hosting account (this is the only account I am able to successfully send from). For RECEIVING, I've only successfully gotten my gmail address to work. All other receiving addresses don't always give me error, but also never show up. Either that, or I get very weird errors. The most common one I get is "Unaable to send mail. 533 5.7.1 AUTH command is not enabled."
    I haven't been able to find this error documented anywhere online. I'd like to be able to send emails to my icloud account, since it pushes email notifications to my phone in real time.
    Long ago someone by the name of Ko Maruyama supposedly explained all this in detail, but the writeup was posted on a .mac website (http://homepage.mac.com/komaruyama/Tutorials/AE/AE_javamail/AE_mail.html), which Apple officially discontinued/took down several years ago.
    Does anyone have any experience with this?

    For Mac, the path is of course slightly different. If you cannot delete the file, you should at least be able to edit it in Extend Script Toolkit or any text editor or run the script separately to change its config data. Works for me...
    Mylenium

  • Grabbing Folder size and email info

    Hi all,
     I've been working on a script that will get the size of all the users profiles folders on our file server. I then set it up to email the I.T. Dept if the size of the file is over 200MB.
    So far, when I run the script, it doesn't throw off any errors, but it doesn't send the email either.
    Information:
    The file server is added as a relay in Exchange.
    We are not using port 25, we're using an alternate port instead.
    I've tried it with both authenticate and without.
    I can telnet to the Exchange server using Putty and open a connection to the port to issue an HELO command.
    I am just learning how to script.
    The script is pasted below with the obvious omitted.
    Since the script doesn't throw an error, I can't track down the problem.
    Script us below.
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objFolder = objFSO.GetFolder("D:\Profiles")
    Set colSubfolders = objFolder.Subfolders
    For Each objSubfolder in colSubfolders
    foldersize = objsubfolder.Size/1024/1024                           
    Next  
    If foldersize > 200 Then
    Set objMessage = CreateObject("CDO.Message")
      objMessage.From = [email protected]"
      objMessage.To = "[email protected]"
      objMessage.Subject = " A profile Folder has exceeded 200MB"
      objMessage.TextBody = "The folder " & objSubfolder & " has exceeded 200MB.  Please panic in an orderly fashion." 
      objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
      objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "myemailserver"
      objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 2525
      objMessage.Configuration.Fields.Update 
      objMessage.Send
    End If
    SO, as I said, it's not throwing an error, but I'm not getting a test email eihter
    What am I missing?

    Yes, we want one email sent, per folder.
    I'm pretty sure I understand why the OP wasn't working. I had foldersize being read, but, the script had no idea of what to do with it as I had the "Next" statement before telling the script what to do with the folders who's size was more than
    200MB.
    That is partly the answer. Immediately it satisfies the need but ask yourself...why didn't you see that to begin with.  Now look at a more direct method of "saying " the same thing in code.
    Set objMessage = CreateObject("CDO.Message")
    objMessage.From = "myemail.com"
    objMessage.To = "myemail.com"
    objMessage.Subject = " A profile Folder has exceeded 200MB"
    objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
    objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "myexchangeserver"
    objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = myport
    objMessage.Configuration.Fields.Update
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objFolder = objFSO.GetFolder("D:\Profiles")
    For Each objSubfolder in objFolder.Subfolders
    If foldersize > objSubfolder > (1024*1024*200) Then
    objMessage.TextBody = "The folder " & objSubfolder & " has exceeded 200MB. Please panic in an orderly fashion."
    objMessage.Send
    End If
    Next
    Note that most of the scrip only needs to be crated once.  This is faster, more efficient, easier to maintain and easier to understand.
    As Mike pointed out.  Skip VBScript and learn PowerShell.
    Same thing in PowerShell
    dir \users -dir |
    Where{($_|get-childitem -recurse -ea 0|Measure-Object length -sum).Sum -gt 200Mb}|
    ForEach{ Send-MailMessage @props -Body "folder too big $($_,Fullname)"}
    ¯\_(ツ)_/¯

  • Printing and email script/button

    I have a form that will be deployed out to employee's laptops that they will use to generate a quote to customers. I need a button that will print the said form as a static pdf document (none of the controls are active that can change the price) and then email the static pdf document form to the customer.
    I was able to generate the button to generate the email with the form as an attachment but the form is still dynamic using the following script:
    var To = mail.rawValue;
    var Subj = "Direct Drive AC Start System Upgrade";
    var Bod = "Please find attached the requested package system upgrade data sheet with pricing.";
    var bc = "[email protected]";
    var cc = "[email protected]";
    Subj = Subj +"( "+InquiryNo.rawValue+" )";
    event.target.submitForm({cURL:"mailto:"+To+"?subject="+Subj+"&Cc="+cc+"&bcc="+bc+"&&body=" +Bod,cSubmitAs:"PDF",cCharset:"utf-8"});
    I also tried setting all the fields as readonly before generating the email but with no success:
    for (var nPageCount = 0; nPageCount < xfa.host.numPages; nPageCount++) {
    var oFields = xfa.layout.pageContent(nPageCount, "field");
    var nNodesLength = oFields.length;
    // Set the field property.
    for (var nNodeCount = 0; nNodeCount < nNodesLength; nNodeCount++) {
    oFields.item(nNodeCount).access = "readOnly";
    Any help will be greatly appreciated.

    Hi ,
    I have made a template in Designer and m generating the Pdf's using the Output ES tool. I want to control the saving and printing options of the Pdf generated. Kindly help ...

  • Folder action to find and replace text and change line feeds

    I want to use a folder action to find and replace text and change Mac carriage returns to DOS line feeds inside text files.
    The text to be replaced is: "/Users/wim/Music/iTunes/iTunes Music/Music" (without the quotes)
    This text has to be removed (i.e. replaced by an empty string)
    The text occurs many times within each file.
    The files are playlists exported from iTunes in the M3U format (which are text files). They contain Mac carriage returns. These need to be changed to DOS line feeds.
    I have found the following two perl commands to achieve this:
    To find and replace text: perl -pi -w -e 's/THIS/THAT/g;' *.txt
    To change carriage returns to line feeds: perl -i -pe 's/\015/\015\012/g' mac-file
    I know that it's possible to make a folder action with Automator that executes a shell script.
    What I want to do is drop the exported playlists in M3U format in a folder so that the folder action will remove the right text and change the carriage returns.
    My questions are:
    Is it possible to make a folder action that executes command line commands instead of shell scripts?
    What is the correct syntax for the two commands when used in a folder action shell script? Especially, how do I escape the slashes (/) in the string to be removed?
    Thanks for your help

    Ok, I've include an applescript to run a shell command. The applesript command quoted form makes a string that will end up as a single string on the bash command line.  Depending on what you want to do, you may need multiple string on the bash command lines.  I've included some information on folder actions.
    It is easier to diagnose problems with debug information. I suggest adding log statements to your script to see what is going on.  Here is an example.
        Author: rccharles
        For testing, run in the Script Editor.
          1) Click on the Event Log tab to see the output from the log statement
          2) Click on Run
        For running shell commands see:
        http://developer.apple.com/mac/library/technotes/tn2002/tn2065.html
    on run
        -- Write a message into the event log.
        log "  --- Starting on " & ((current date) as string) & " --- "
        --  debug lines
        set desktopPath to (path to desktop) as string
        log "desktopPath = " & desktopPath
        set unixDesktopPath to POSIX path of desktopPath
        log "unixDesktopPath = " & unixDesktopPath
        set quotedUnixDesktopPath to quoted form of unixDesktopPath
        log "quoted form is " & quotedUnixDesktopPath
        try
            set fromUnix to do shell script "ls -l  " & quotedUnixDesktopPath
            display dialog "ls -l of " & quotedUnixDesktopPath & return & fromUnix
        on error errMsg
            log "ls -l error..." & errMsg
        end try
    end run
    How to set up a folder action.
    1) right click on folder. click on Enable folder actions
    2) Place script in
    /Library/Scripts/Folder Actions Scripts
    3) right click on folder. click on attach folder action
    pick your script.
    Create a new folder on the desktop & try.
    You can put multiple folder actions on a folder. There are other ways of doing this.
    Here is my test script:
    on adding folder items to this_folder after receiving dropped_items
        repeat with dropped_item_ref in dropped_items
           display dialog "dropped files is " & dropped_item_ref & " on folder " & this_folder
        end repeat
    end adding folder items to
    How to  make the text into an AppleScript program.
    Start the AppleScript Editor
    /Applications/AppleScript/Script Editor.app
    In Snow Leopard it's at: /Applications/Utilities/AppleScript Editor
    Copy the script text to the Applescript editor.
    Note: The ¬ is typed as option+return.  ption+return is the Applescript line continuation characters.
    You may need to retype these characters.
    Save the text to a file as an script and do not check any of the boxes below.

  • 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?

  • 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,

  • Folder action delay until done

    I run a video encoding software called Episode Engine, and what it does is while encoding a video, it kicks out a temporary file in the output folder with a file size of 0. It does not actually update the filesize until encoding is complete.
    What I want to do is set a folder action to an output folder (which receives up to 5 videos at a time from encoding) that uploads the file automatically to a Transmit (FTP Client) favorite. I also want to account for the fact that I may drop large files in this folder as well, which could take time, but dont stay at 0 file size until the transfer is done. The part I'm having trouble with is delaying the transmit action until the file is done encoding. What I currently have does not work. And I dont know any way to monitor a folder action workflow, so I'm not sure where it's failing. Any recommendations?
    p.s. We're still running 10.6.8 on this computer (I know, I know...)
    property DELAY_TIME_SECONDS : 5 -- How long to wait between checking file size.
    on adding folder items to thisFolder after receiving theItems
         repeat with f in theItems
                             set currSize to 0
                             set oldSize to 0
                             set newSize to -1
                             repeat while currSize is 0
                                            delay 2
                                            set currSize to size of (info for f)
                             end repeat
                             repeat while newSize is not equal to oldSize
                                            -- Get the file size.
                set oldSize to size of (info for f)
                delay DELAY_TIME_SECONDS
                 -- Sample the size again after delay for comparison.
                                            set newSize to size of (info for f)
                             end repeat
         end repeat
    end adding folder items to

    Folder Actions has some built in support for recognizing 'busy' files, but it's not too intelligent.  It works well with Finder moves and copies, not so well with other things.  There are three ways I can think of to solve this problem.
    Tweak your script with a test for temp files so that it skips them.  This may cause secondary headaches (e.g. you skip a temp file, but Lightroom finishes the job in the ten second throttle period so the creation of the the file(s) you want to move is missed by folder actions), but there's no way to tell unless you try.
    Drop Folder Actions and set up a QueueDirectories launch agent.  This would wait for items to be added to the folder then move and delete them - you write the script to idle until temp files are done processing.
    Forget about immediate gratification and write a LaunchAgent that will sync the folders hourly using rsync.
    Which would you prefer?

  • Help Needed: Automator Applescript for Folder Action - Encode Video

    Hi !
    I have created an Automator Applescript for a Folder Action to do the following:
    When a new video file is moved to the target folder (i.e. Download of Vuze is done), automatically launch the Applescript Action that does the followin g(Applescripted):
    1) Using "run shell script" and FFMPEG on a UNIX command line, determine Width/Height, Framerate, Bitrate
    2) Calculate encoding parameters (slightly reduced bitrate, reduced Aspect etc.)
    3) Using "run shell script" with ffmpeg on the command line and the calculated parameters to encode the video file
    At the same time, the action is written to a log file so I know if a file is recognized, when encoding started etc.
    It works fine if I save this Action as an .app, make an alias on the Desktop and drop video files on it.
    It also works fine if I attach the script to a folder as a folder action and drag a video file in there.
    However, when I attach the script as a folder action to the Vuze download folder, it encodes only some video files, i.e. if there was a download of 5 files, chances are good that it will not encode 1 or 2 files out of those 5.
    If for example a second download finishes while the encoding for the first download is still going on, sometimes the second file starts encoding after the first encode finishes, sometimes it does not, the file does not make the log file at all, i.e. the folder action missed it or the automator action dropped it because it was still encoding. Still, sometimes it happens, sometimes not.
    As I need a solution that is 100% accurate, I would like to ask if there are any ideas on how to do this better maybe? As I am not an Applescript Guru, I would need some help to know what works and what doesn't and what the syntax is.
    My main idea right now:
    Similar to how ffmpegX works with its "process" application, have a second script (as .app) that receives the files to be encoded from the automator action and puts them in a queue, then proceeds to encode this queue while the main automator action is free to receive the next file.
    Writing this second app is quite straightforward (a modified version of my current script) but I have some questions I need help with:
    1) How do I call another applescript from within an existing applescript that launches the new applescript in a new process?
    2) How do I pass parameters to this new applescript?
    3) In case of this "Queueing" Idea, once I called the external applescript the first time, how do I make sure when I call next time, that I don't open a second instance of this script but rather pass another queue item to the original instance to be processed?
    Or in general: Is there a better way to achieve this automatic encoding solution that I have not thought about?
    Alternatively:
    Does anyone know how to call the "process" application that comes with the ffmpegX package with the correct parameters to use as a queueing / processing tool?
    Thanks!
    Joe
    Message was edited by: Joe15000
    Message was edited by: Joe15000

    To do this, I created an Automator workflow with an Applescript snippet to change the 'media kind'.
    Here is the 'Run Applescript' workflow step code:
    on run {input, parameters}
              tell application "iTunes"
                        set video kind of (item 1 of input) to movie
              end tell
              return input
    end run
    Prior to this running, I have an 'Import Files into iTunes' workflow step.
    You can switch out 'movie' with: 'TV show', 'music video', or anything in ITLibMediaItemMediaKind.
    Good luck,
    Glenn

  • Downloads Folder Action

    Hello,
    I found a simple shell script that will help keep my Downloads folder organized by modification date. I used Automator to create a Finder Plug-In that's nothing but a Run Shell Script action: touch "$." Works great. I saved it as a folder action and attached it to my Downloads folder, but it won't work as a folder action. I added a Wait for Files to Copy action (testing with a pdf extension and download), and it still doesn't work. I tried to attach it to a dummy folder on my desktop that I directed Safari to save downloads to, still wouldn't work. I've saved it as a script, and attached it to the folder as a script, no joy. Will someone please help me with this. It should be very simple, I just want the items to be touched without having to touch each one myself.
    I have checked permissions on my user folder and Downloads folder, also deleted ~/Library/LaunchAgents/com.apple.FolderActions.enabled.plist and com.apple.FolderActions.folders.plist, logged out/in, disabled and re-enabled folder actions. Also, I have another folder action attached to my Downloads (Unquarantine), and it seems to work fine.
    Thanks in advance for any help,
    Jess

    I'm closing this question because the folder actions somehow work now. I must have shut down/started up enough times, or done something inadvertently to kick it into gear. I frequently have to check to make sure the folder actions are enabled, but other than that, my script works like a charm! Thanks for giving this your attention.
    Jess

  • Folder action kicks in too early

    I have a little applescript that is to add all files that are added to a specific folder to an iTunes playlist.
    I added the script as a folder action to the folder.
    It seems to work fine with single files.
    However, when I copy several files (which takes a few seconds), then the script gets started too early, i.e., when only half of the files have been copied over. Consequently, only some of the files get added to the playlist.
    In addition, when I copy a large number of files, it doesn't seem to work at all.
    Any ideas what's wrong? or what I can do?
    (Is this a bug in Mac OS? I read about an issue in 10.5 where folder actions got started before a single files was finished copying, but I haven't seen of any hints about my problem.)
    Any kind of help will be highly appreciated.
    Best regards,
    Gabriel.
    PS:
    Here is my script, for completeness
    Automatically add the files that are dropped on this applescript to
    playlist named below.
    To adapt it for a different playlist, just change the name below and save as application.
    In addition, you can add this script as a folder action
    Author: Gabriel Zachmann, Feb 2010
    property playListName : "Hoerspiele"
    on open theseFiles
    addTheFiles(theseFiles)
    end open
    on adding folder items to this_folder after receiving added_items
    addTheFiles(added_items)
    end adding folder items to
    to addTheFiles(theFiles)
    tell application id "com.apple.iTunes"
    activate
    set playL to some playlist whose name is playListName
    set playID to persistent ID of playL
    --display dialog ("persistent ID = " & playID) buttons {"OK"} default button 1
    reveal (some playlist whose persistent ID is playID)
    repeat with aFile in theFiles
    try
    add aFile to some playlist whose persistent ID is playID
    end try
    -- set new date, so we know later when we copied the files
    set the file_path to the quoted form of the POSIX path of aFile
    do shell script ("/bin/touch " & file_path)
    end repeat
    end tell
    end addTheFiles
    Message was edited by: GabrielZ

    folder actions have always been buggy and this has always been an issue when folder actions have to process many files at the same time. it's supposed to have gotten better in snow leopard but it's still very far from being reliable. you can try the following trick to slow down your folder action and make it wait to process individual items before they are all copied. that might (or might not ) help
    http://discussions.apple.com/message.jspa?messageID=8277780#8277780

  • Failed to attach workflow to "Downloads" as a folder action

    Hi, everyone
         I am trying to move the files and folders I get via AirDrop to a folder named AirDrop with automator. I use the following workflow
         Folder Action receives files and folders added to Downloads
         Get Specific Finder Items (Downloads)
         Get Folder Contents (Un-tick Repeat for Subfolder found)
         Filter Finder Item ( All of following are true : Name is not AirDrop )
         Move Finder Item ( To AirDrop : tick Replace existing files)
         It works perfectly fine when I tries to run it step by step or using Run button. But it doesn't work when I add a file or folder to the Downloads folder. So, I tried to remove the .workflow file from the Folder Actions and re-install it again. When I do that, this
    occurred.
         Please help me. Thanks in advance

    a rough draft of the script that answered my own question:
    tell application "Microsoft Word"
      activate
    end tell
    tell application "System Events"
      delay 0.5
      keystroke "a" using command down
      tell application process "Microsoft Word"
      click menu item "Page Setup..." of menu "File" of menu bar item "File" of menu bar 1
      delay 1
      click pop up button 3 of window "Page Setup"
      keystroke "Any"
      delay 0.5
      keystroke return
      delay 0.5
      keystroke return
      delay 1
      click menu item "Print..." of menu "File" of menu bar item "File" of menu bar 1
      delay 1
      tell menu button "PDF" of window "Print"
      click
      click menu item "Create Booklet" of menu 1
      end tell
      end tell
    end tell

  • AppleScript Folder Actions

    I'm new to this group, and my question may have been answered a long time ago as I'm using OS 10.5.8. I've been teaching myself AppleScript, and have been using "AppleScript - The Missing Manual" by Adam Goldstein and "AppleScript 1-2-3" by Sal Soghoian and Bill Cheeseman. All has gone well until now. I'm working on a couple of folder actions and have hit a wall. I've successfully written "on opening..." and "on closing..." actions. However, I have been 100% UNsuccessful at writing "on adding folder items to..." scripts. Action scripts are saved in the proper location, are attached properly, and folder actions are enabled. I turned a primary "on adding..." script (one I started out to do) into a droplet, and it functions perfectly when files are dropped on it. Help in explaining to me "the error of my ways" would be appreciated.

    If there is an error in a folder action script, it tends to fail silently - for example, your *opening folder* script will fail because you are not coercing theCount (a number) to text (display dialog doesn't like lists, which is what you are getting by concatenating a string to a number).
    Since you have a droplet that works correctly, you can just add a folder action handler to that script. I use a folder action template that includes handlers so that it can be run and tested from the *Script Editor* (it can also be used as a droplet). In the following example, the doStuff handler is what does the stuff, and the other handlers (including the folder action) just pass items to it.
    <pre style="
    font-family: Monaco, 'Courier New', Courier, monospace;
    font-size: 10px;
    font-weight: normal;
    margin: 0px;
    padding: 5px;
    border: 1px solid #000000;
    width: 720px; height: 340px;
    color: #000000;
    background-color: #FFD891;
    overflow: auto;"
    title="this text can be pasted into the Script Editor">
    on run -- application double-clicked or run from the Script Editor
    tell application "Finder" to try
    set someItems to (the selection) as alias list
    on error errorMessage number errorNumber
    set someItems to (the selection) as alias as list
    end try
    if someItems is {} then set someItems to (choose file with multiple selections allowed)
    doStuff for someItems
    return
    end run
    on open theFiles -- items dropped onto the application
    doStuff for theFiles
    return
    end open
    on adding folder items to this_folder after receiving these_items
    handle items added to a folder
    parameters - this_folder [alias]: the folder added to
    these_items [list]: a list of items (aliases) added
    returns nothing
    doStuff for these_items
    return
    end adding folder items to
    to doStuff for someFiles
    do stuff with each file in someFiles
    parameters - someFiles [list]: a list of files to do stuff with
    returns nothing
    repeat with anItem in someFiles
    try
    -- do stuff, for example:
    tell application "Finder"
    set theName to name of anItem
    considering case -- case sensitive match
    if "-P" is in theName then
    move anItem to alias "HD:Users:myself:Property:All Property"
    else if "-GP" is in theName then
    move anItem to alias "HD:Users:myself:Photography:General Photos"
    else
    log "no match"
    end if
    end considering
    end tell
    on error errorMessage number errorNumber -- oops
    log errorMessage
    -- activate me
    -- display alert "Error " & errorNumber message errorMessage
    end try
    end repeat
    return
    end doStuff
    </pre>

  • Folder action starts twice

    This is wicked frustrating. All I'm creating is a simple automator action. It consists of 2 items - the "Run Shell Script" and a Growl Notification. In the shell script there is a single line to call a perl script.
    I saved this as a folder action, and every time I drop something into it everything runs twice. I see the growl notification twice as well as in a log file that is written by the perl script.
    The really frustrating part is that it was working 100% correctly, I removed an unnecessary "Get Specified Finder Items" step in the very beginning, and now it is doing this running twice thing. It still does it after I Time Machine restored back to the copy that was originally working. I have also right clicked the first action and told it to ignore input.
    I've tried deleting everything, deleting and disabling the folder action so I would be starting clean from scratch. I recreated the script and it's still running twice. A different folder action works fine.
    Any help is greatly appreciated. Thanks!
    Message was edited by: mcewen98

    At one point there were 2 copies, one called {name}.app and another just {name}. I'm not sure how that happened, but I fixed it before posting. There are 2 scripts in Library/Workflows/Applications/Folder Actions now, but they are named differently and are for 2 different things. The other one works fine.
    I think I may be on to something. If I remove the "run shell script" action, leaving only the growl action, save, and test, then the message is only displayed once. When I add the "run shell script" action (regardless of what the shell script actually runs - right now I'm only telling it to echo "test") I get the message twice.
    Also, whenver I test within Automator it works correctly. The problem only happens when I exit out and then drop something into the folder using the finder. I also checked the folder action configuration. There are 2 folders listed, the one having the problem has a single script. If I edit the script the path to the .app is correct. This is the file that I'm editing in Automator.
    Message was edited by: mcewen98

  • Folder Actions not working

    I'm trying out folder actions for the first time, and I cannot get an action to trigger.
    I regularly use Automator, and I've saved a script as a Folder Action plug-in attached to a folder. I've tried this with several different scripts.
    For example, I've got a script that just displays a message. It works fine if I save it as an app, so I save it as a Plug In>Folder Action. If I select, say, my documents folder, I right click>more>attach a folder action. I then select my script. If I open the Folder Actions Setup, my script is listed as attached to my documents folder. However, if I drop a file into the Documents folder, nothing happens.
    Am I correct in thinking that the script should run when a file is dropped into the folder (and if I'm wrong, how would you do this?), or have I missed something?
    I'm using 2x 2,8GHz Quad-Core Intel Xeon Mac, OsX 10.5.6.
    Cheers
    Steve

    In the Finder (Mac) Help, every user may read:
    *+Running an automation when a folder is changed+*
    +Folder actions let you run automations when a folder is modified. For example, you could run an AppleScript or an Automator workflow whenever something is added to a dropbox folder.+
    +To use folder actions, you attach a folder action script or workflow to a folder. When the folder is opened, closed, or modified, the automation will be activated automatically.+
    +Your script must include a handler for each folder action command used.+
    +To make a folder action scripts available to all users of your computer, put them in the Folder Action Scripts folder located at:+
    +Library/Scripts/Folder Action Scripts/+
    +To make the scripts available only to the current user, put them in the home folder at:+
    +~/Library/Scripts/Folder Action Scripts/+
    *+To enable folder actions:+*
    +1. Open Folder Actions Setup in the Applications/AppleScript folder.+
    +2. Select Enable Folder Actions.+
    +3. Click the ╋ button below the Folders with Actions list and choose the folder containing the folder actions.+
    +4. Click the ╋ button below the Script list and select the desired scripts, then click Attach.+
    My guess is that you missed one of the four steps.
    Yvan KOENIG (from FRANCE vendredi 5 juin 2009 17:09:05)

Maybe you are looking for

  • Bookmark search in location bar does not produce proper results

    (note: I have hundreds of bookmarks) I search the word "idea" in the location bark (with prefs set as searching for Bookmarks) and only SOME of the bookmarks with "idea" in the name come up. I type "ideas" and they all disappear, even though there IS

  • Payment of travel and subsistence with FI using bank details in HR module

    We have implemented the HR and FI module for a client. They have a requirement that they would like to pay S&T in FI using employees details in HR without creating the employees as vendors in FI. How can the FI module access the bank details of the e

  • How to make coldfusion identify my ID in network?

    I am build a intranet site with coldfusion 7. Do you think if the coldfuison can get the person's network ID or person's active directory ID when a person access the intranet site? What is the syntax to do this if it is possible. Thanks Mark

  • Does the final Release 5.1 Support ear type deployment in Weblogic

    I down loaded final Release 5.1 and trying to find deploying different modules using using ear (Enterprise Archieve), I can not find any documents. Does the final Release support ear type deploying or not. Regards Krishna

  • Building a "Wizard" Form

    Hi, I'm not a Forms expert, but I was wondering if the following is possible: building a generic Form that has the Windows-Wizard look-and-feel, and controls the order in which other Forms are displayed and which data is passed between the Forms disp