Skip navigation

Folder Action does not run on SECOND file only

2620 Views 15 Replies Latest reply: Aug 16, 2013 5:08 AM by Warwick Teale RSS
1 2 Previous Next
Chris Wanja Calculating status...
Currently Being Moderated
Mar 7, 2012 5:12 PM

Does any one know of a bug or a log for folder scripts that do not run? I am trying to get a basic folder script (to replace %20 in the file name) of the Downloads folder.

 

When downloading multiple files (two or more) it runs only on the first file, successfully without error, and then never runs on the second file. If I move both of the files out of the Downloads folder and move it back it, the one file that does not get the folder action now does and everything is peachy.

 

So it is not that the folder action is not scripted properly. It is just that the folder does not catch the second file download - guess maybe too fast? Has any one seen this or have this bug?

 

Regards,

Chris Wanja

15" Unibody MacBook Pro , Mac OS X (10.6.4)
  • red_menace Level 6 Level 6 (14,275 points)
    Currently Being Moderated
    Mar 7, 2012 5:57 PM (in response to Chris Wanja)

    The folder action will trigger when the first file hits the attached folder, so if the downloads are not complete you will need to add some kind of check or delay.  Hard to tell without seeing the script - a folder action will also fail silently if there is an untrapped error.

  • fop.net Calculating status...
    Currently Being Moderated
    Apr 20, 2012 5:58 PM (in response to red_menace)

    Chris i have the same problem, i've implemented a script and i 've attached about 1000 folders, and than when i copy more than one file to one of theses folders, or some files are copied or it is never trigged, sometimes it simply does not work!!

     

    I did a test, i run this applescript [tell application "System Events" to activate"] before copy the files, but it kept unstable, sometimes it works, sometime it does not work!

     

    i did not found anything about this subject on the Internet.

     

    Please i need some help to solve this problem

  • twtwtw Level 5 Level 5 (4,580 points)
    Currently Being Moderated
    Apr 20, 2012 11:33 PM (in response to fop.net)

    Folder actions can be spotty, particularly when doing tasks that involve the Finder.  I think what happens is that triggering a folder action script will make the dispatcher miss any files added while the script is running (and for a throttle period after), so adding files faster than about once every ten seconds can cause problems.  Of course, the dispatcher is supposed to check periodically for missed files, but the default time for that is fairly long (3 minutes), and I'm not entirely convinced it works as advertised.

     

    There are workarounds and alternate approaches, but we'd need to see the script in question.

  • twtwtw Level 5 Level 5 (4,580 points)
    Currently Being Moderated
    Apr 21, 2012 10:09 AM (in response to Chris Wanja)

    Need more details:

     

    • Are you using the Finder, System Events.app, or unix to change the file names?
    • If you move in two or more files in the same drag, do they all get processed or just the first one?
    • Do you get any errors in Console.app when the Folder action runs?
    • If the script fails to fix a file, and you leave it alone for 15 minutes, is the file fixed in the interim?
  • fop.net Level 1 Level 1 (0 points)
    Currently Being Moderated
    Apr 24, 2012 6:04 AM (in response to Chris Wanja)

    In my case, i use both solutions

     

    1- Automator running rsync (unix) to copy files, and i use the Finder to copy the new files to my external HD

    2- When i use Finder, sametimes the event dispatch my actionscript, and move all files sucessfully but other moment it does not. In both of cases, the Folder Action Dispatcher and System Event process are in memory.

    3- No erros in console, the script is very tested, it´s ok.

    4- My case the files was not copied.

     

    I use this handle to capture my folder events "on adding folder items to this_folder after receiving added_items"

    I have more than a thousands foders with the same script activated.

     

    My problem is: The system does not trigger a folder action script, or the delay is very big.

  • fop.net Level 1 Level 1 (0 points)
    Currently Being Moderated
    Apr 24, 2012 7:44 AM (in response to fop.net)

    My system requirements:

    OsX Lion 10.7.3

    8 GB RAM

  • twtwtw Level 5 Level 5 (4,580 points)
    Currently Being Moderated
    Apr 24, 2012 2:44 PM (in response to Chris Wanja)

    well, with a little testing the problem seems to be that the Finder/System Events don't queue up apple events properly.  Folder actions seems to be running the script at each invocation but it's not getting picked up by the app at the other end when that app is busy.  a delay statement might help, or you might try rewriting the workflow so that it checks every file in the folder, rather than just the ones passed by the folder action.

  • fop.net Level 1 Level 1 (0 points)
    Currently Being Moderated
    Apr 25, 2012 4:43 PM (in response to twtwtw)

    In reply to twtwtw

     

     

    I think this is a system problem, the system could not fail to execute a script for any  unavailability of another application, and it can open another instance of it,
    On the other hand, to implement something to bypass that was scheduled by the mac osx, it would not begood behavior.

    I cleared my log, and found a bug of unknown cause, or by executor or by implemented code.

     

     

     

     


     

     

     

    25/04/12 20:15:00,171 com.apple.launchd.peruser.501: (com.apple.quicklook.config[6284]) Bug: launchd_core_logic.c:4230 (25397):9

    25/04/12 20:15:00,172 com.apple.launchd.peruser.501: (com.apple.quicklook.config[6284]) Bug: launchd_core_logic.c:4180 (25397):9

    25/04/12 20:15:00,172 com.apple.launchd.peruser.501: (com.apple.quicklook.config[6284]) Bug: launchd_core_logic.c:4181 (25397):9

    25/04/12 20:15:00,172 com.apple.launchd.peruser.501: (com.apple.quicklook.config[6284]) Bug: launchd_core_logic.c:4182 (25397):9

    25/04/12 20:15:00,172 com.apple.launchd.peruser.501: (com.apple.quicklook.config[6284]) Bug: launchd_core_logic.c:4189 (25397):9

    25/04/12 20:18:07,417 com.apple.launchd.peruser.501: ([0x0-0x35035].com.apple.AppleScriptRunner) Bug: launchd_core_logic.c:4151 (25397):24

    25/04/12 20:18:07,418 com.apple.launchd.peruser.501: ([0x0-0x35035].com.apple.AppleScriptRunner) Bug: launchd_core_logic.c:4224 (25397):9

    25/04/12 20:18:07,418 com.apple.launchd.peruser.501: ([0x0-0x35035].com.apple.AppleScriptRunner[6869]) Bug: launchd_core_logic.c:4180 (25397):9

    25/04/12 20:18:07,418 com.apple.launchd.peruser.501: ([0x0-0x35035].com.apple.AppleScriptRunner[6869]) Bug: launchd_core_logic.c:4181 (25397):9

    25/04/12 20:18:07,418 com.apple.launchd.peruser.501: ([0x0-0x35035].com.apple.AppleScriptRunner[6869]) Bug: launchd_core_logic.c:4182 (25397):9

    25/04/12 20:18:11,601 AppleScript Runner: CPSGetFrontProcess(): This call is deprecated and should not be called anymore.

    25/04/12 20:18:11,665 com.apple.launchd.peruser.501: ([0x0-0x36036].com.apple.AppleScriptRunner) Bug: launchd_core_logic.c:4151 (25397):24

    25/04/12 20:18:11,666 com.apple.launchd.peruser.501: ([0x0-0x36036].com.apple.AppleScriptRunner) Bug: launchd_core_logic.c:4224 (25397):9

    25/04/12 20:18:11,666 com.apple.launchd.peruser.501: ([0x0-0x36036].com.apple.AppleScriptRunner[6880]) Bug: launchd_core_logic.c:4180 (25397):9

    25/04/12 20:18:11,666 com.apple.launchd.peruser.501: ([0x0-0x36036].com.apple.AppleScriptRunner[6880]) Bug: launchd_core_logic.c:4181 (25397):9

    25/04/12 20:18:11,666 com.apple.launchd.peruser.501: ([0x0-0x36036].com.apple.AppleScriptRunner[6880]) Bug: launchd_core_logic.c:4182 (25397):9

    25/04/12 20:18:15,801 AppleScript Runner: CPSGetFrontProcess(): This call is deprecated and should not be called anymore.

    25/04/12 20:18:15,869 com.apple.launchd.peruser.501: ([0x0-0x37037].com.apple.AppleScriptRunner) Bug: launchd_core_logic.c:4151 (25397):24

    25/04/12 20:18:15,869 com.apple.launchd.peruser.501: ([0x0-0x37037].com.apple.AppleScriptRunner) Bug: launchd_core_logic.c:4224 (25397):9

    25/04/12 20:18:15,870 com.apple.launchd.peruser.501: ([0x0-0x37037].com.apple.AppleScriptRunner[6891]) Bug: launchd_core_logic.c:4180 (25397):9

    25/04/12 20:18:15,870 com.apple.launchd.peruser.501: ([0x0-0x37037].com.apple.AppleScriptRunner[6891]) Bug: launchd_core_logic.c:4181 (25397):9

    25/04/12 20:18:15,870 com.apple.launchd.peruser.501: ([0x0-0x37037].com.apple.AppleScriptRunner[6891]) Bug: launchd_core_logic.c:4182 (25397):9

    25/04/12 20:18:20,227 AppleScript Runner: CPSGetFrontProcess(): This call is deprecated and should not be called anymore.

    25/04/12 20:18:46,506 Dock: kCGErrorIllegalArgument: CGSSetWindowListGlobalClipShape: Invalid window 0x7d

    25/04/12 20:18:46,506 Dock: kCGErrorFailure: Set a breakpoint @ CGErrorBreakpoint() to catch errors as they are logged.

    25/04/12 20:18:46,530 Dock: kCGErrorIllegalArgument: CGSSetWindowTransformsAtPlacement: Failed

    25/04/12 20:18:46,545 Dock: kCGErrorIllegalArgument: CGSSetWindowListGlobalClipShape: Invalid window 0x7d

    25/04/12 20:18:46,546 Dock: kCGErrorIllegalArgument: CGSSetWindowTransformsAtPlacement: Failed

    25/04/12 20:18:46,546 Dock: kCGErrorIllegalArgument: CGSOrderWindowListWithOperation

    25/04/12 20:18:46,547 Dock: kCGErrorIllegalArgument: CGSOrderWindowList

  • fop.net Level 1 Level 1 (0 points)
    Currently Being Moderated
    Apr 25, 2012 4:59 PM (in response to fop.net)

    A overview of my applescript

     

     

    on adding folder items to this_folder after receiving these_items

              set pFileWatchedFolder to copyItems(these_items)

     

              if pFileWatchedFolder is not missing value then speak(ioLib's getDisplayName(pFileWatchedFolder))

     

    end adding folder items to

     

    on copyItems(these_items)

              local pFileWatchedFolder

              set pFileWatchedFolder to missing value

     

              try

     

                        repeat with i from 1 to number of items in these_items

                                  set als_item to item i of these_items as alias

                                  set strItemPath to als_item as alias as Unicode text

     

                                  set pFileWatchedFolder to ioLib's getWatchedFolder(als_item, pFileWatchedFolder, myWatchedFolders)

                                  if pFileWatchedFolder is missing value then

                            return pFileWatchedFolder

                                  end if

     

     

                                  set this_watched to pFileWatchedFolder as alias as Unicode text

     

                                  set remotePath to ioLib's getRemotePath(this_watched, strItemPath, myRemoteFolder)

                                  set targetPath to ioLib's getTargetPath(remotePath)

     

                                  tell application "Finder"

     

      -- verificando se o destino é uma pasta ou um arquivo

                                            if ioLib's isFolder(strItemPath) then

      ioLib's attachFolderAction(als_item, path to me as Unicode text)

     

      -- verifica se a pasta existe

                                                      if not (exists remotePath) then

                                                                set folderName to ioLib's getDisplayName(als_item)

      make new folder at targetPath with properties {name:folderName}

                                                      end if

     

                                                      if length of (list folder strItemPath without invisibles) > 0 then

                                                                     set folderItems to (items of entire contents of folder strItemPath)

     

                                                                     my copyItems(folderItems)

                                                      end if

                                            else if not (exists remotePath) then

      -- Copiando o arquivo 

                                                           if ioLib's isVisibleAlias(als_item) then

               copy file als_item to folder targetPath

                                                           end if

                                            end if

     

                                  end tell

     

                        end repeat

     

     

                        return pFileWatchedFolder

              on error errStr

           display alert errStr

              end try

     

    end copyItems

     

     

    ------------------------------------------------

    ------- Metodos Utilitários --------------

    ------------------------------------------------

     

    on speak(str)

              say str & " backup, complete."

    end speak

  • fop.net Level 1 Level 1 (0 points)
    Currently Being Moderated
    Apr 25, 2012 5:57 PM (in response to fop.net)

    other error found

     

    25/04/12 21:50:17,306 com.apple.launchd.peruser.501: (com.apple.FolderActions.folders) Path monitoring failed on "/Users/Felipe/Projects/Growupge/webapps/examples/jsp/security/protected": Too many open files

     

    ????

     

    There are a lot of kind of errors like this, what is the reason ?

  • fop.net Level 1 Level 1 (0 points)
    Currently Being Moderated
    Apr 25, 2012 6:04 PM (in response to fop.net)

    Captura de Tela 2012-04-25 às 21.59.33.png

     

    Look at the memory usage !!!

     

    Why there are two instance of the same process in memory ?

     

    These dispatcher have not scalability, or it works only for two or three folders ?

  • pjdube Level 3 Level 3 (830 points)
    Currently Being Moderated
    Mar 19, 2013 4:49 PM (in response to Chris Wanja)

    This Automator action will handle your problem.

     

    Screen Shot 2013-03-19 at 11.10.21 AM.JPG

1 2 Previous Next

Actions

More Like This

  • Retrieving data ...

Bookmarked By (0)

Legend

  • This solved my question - 10 points
  • This helped me - 5 points
This site contains user submitted content, comments and opinions and is for informational purposes only. Apple disclaims any and all liability for the acts, omissions and conduct of any third parties in connection with or related to your use of the site. All postings and use of the content on this site are subject to the Apple Support Communities Terms of Use.