1 2 Previous Next 15 Replies Latest reply: Aug 16, 2013 5:08 AM by Warwick Teale
Chris Wanja Level 1 Level 1 (0 points)

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)
  • 1. Re: Folder Action does not run on SECOND file only
    red_menace Level 6 Level 6 (14,610 points)

    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.

  • 2. Re: Folder Action does not run on SECOND file only
    fop.net Level 1 Level 1 (0 points)

    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

  • 3. Re: Folder Action does not run on SECOND file only
    twtwtw Level 5 Level 5 (4,690 points)

    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.

  • 4. Re: Folder Action does not run on SECOND file only
    Chris Wanja Level 1 Level 1 (0 points)

    For my script, it is pretty simple -- I am away from my computer, but can easily explain it:

     

    It has a Find / Replace. It finds any file in ~/Downloads/ that has %20 and then replaces it with a space ( ) [minus the parentheses).

     

    Pretty simple script if you asked me. But i guess I could see how adding a file to the folder while it is running would cause it to be skipped. My only problem with that explination is that once I remove the file from the folder and then drag it back into the folder it STILL does not fire off. And this could be 10 - 20 seconds after.

     

    Any additional thoughts?

  • 5. Re: Folder Action does not run on SECOND file only
    twtwtw Level 5 Level 5 (4,690 points)

    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?
  • 6. Re: Folder Action does not run on SECOND file only
    fop.net Level 1 Level 1 (0 points)

    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.

  • 7. Re: Folder Action does not run on SECOND file only
    fop.net Level 1 Level 1 (0 points)

    My system requirements:

    OsX Lion 10.7.3

    8 GB RAM

  • 8. Re: Folder Action does not run on SECOND file only
    Chris Wanja Level 1 Level 1 (0 points)

    In reply to twtwtw

     

    • 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?
      • Moving multiple items in (tested with 2, 3, and 4 files); 2 - all were changed, 3 - all were changed, 4 - all were changed
    • Do you get any errors in Console.app when the Folder action runs?
      • Downloaded three files. Two were not renamed. In Console, there were these two errors:
        • 4/24/12 2:18:06.448 PM com.apple.launchd.peruser.501: (com.apple.FolderActions.folders) Throttling respawn: Will start in 2 seconds
    • If the script fails to fix a file, and you leave it alone for 15 minutes, is the file fixed in the interim?
      • After the above, I let the two additional files sit from 2:18 till 2:40. Never changed. No additional Console errors either during that waiting period.
      • There were additional Automator errors (like below), but they looked to only be related to MS Office issues.
        • 4/24/12 2:28:18.201 PM Automator Runner: -[AMApplicationRegistry loadDefinitionAtURL:]: No application name for definition at URL file://localhost/Library/Automator/Office.definition/

     

    Do you think adding in a few second pause after or before the Automator script runs would alleviate the problem? I noticed you can add that. My thoughts on the latter are that it would only help if I was able to download all the files I need in that X number of seconds - IE if I get it to 5 seconds, and I download 20 files, chances are unlikely I won't get through all 20 links in 5 seconds.

     

    My system is:

    10.7.3 Unibody MBP

     

    Appreciate your assistance.

    Regards,

    Chris Wanja

    chris.wanja@gmail.com

  • 9. Re: Folder Action does not run on SECOND file only
    twtwtw Level 5 Level 5 (4,690 points)

    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.

  • 10. Re: Folder Action does not run on SECOND file only
    fop.net Level 1 Level 1 (0 points)

    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

  • 11. Re: Folder Action does not run on SECOND file only
    fop.net Level 1 Level 1 (0 points)

    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

  • 12. Re: Folder Action does not run on SECOND file only
    fop.net Level 1 Level 1 (0 points)

    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 ?

  • 13. Re: Folder Action does not run on SECOND file only
    fop.net Level 1 Level 1 (0 points)

    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 ?

  • 14. Re: Folder Action does not run on SECOND file only
    pjdube Level 3 Level 3 (830 points)

    This Automator action will handle your problem.

     

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

1 2 Previous Next