Apple Event: May 7th at 7 am PT

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

folder action not working mountain lion

Hi I am trying to get Folder Action to work... Even if action is attached to a folder as shown below nothing happens when files copied to "programming" folder?


User uploaded file

MacBook Pro with Retina display, OS X Mountain Lion (10.8.1)

Posted on Aug 24, 2012 6:20 PM

Reply
Question marked as Best reply

Posted on Sep 1, 2012 5:22 AM

I am facing the same issue...even a simple alert script is not getting triggered 😕

41 replies

Nov 20, 2012 1:11 PM in response to Boby51

I have a related problem. A Folder Action for importing images and videos to Aperture works for some files while others are left without being imported. I take out the files that were not imported and put them back into the folder and each time a few files are imported while some are left.


I have also tried to remove the FolderAction preference files without success.


No new on this yet?

Jan 13, 2013 9:59 AM in response to Boby51

Here is another folder action that I wrote recently. This is a bash script that uses embedded AppleScript to pop an alert dialog. If nothing else, it can be an instructional tool.


Here are the steps to setting this up as a folder action.

  1. Create an arbitrary named folder where you want it, including the Desktop.

    I named mine ~/Desktop/file2html

  2. Launch /Applications/Automator
    1. Select Folder Action and then click Choose
    2. In the left library panel, select Utilities > Run Shell Script
      1. Drag and Drop the Run Shell Script action onto the larger workflow panel
      2. Configure it as in the following graphic. Single-click to enlarge. Yours will not have any content yet.
        User uploaded file
      3. Copy and paste the following Bash shell script text into the open action window above. Remove the 4. at the beginning of the text.
      4. # 
        # file2html - folder action workflow script supports
        #             drag and drop file conversion to html.
        #             Unsupported filetypes are displayed in
        #             system dialog box.
        #
        # array for invalid filetypes
        declare -a invalid
        #enable extended regular expressions
        shopt -s extglob
        
        
        # process every file dragged onto the folder
        for file in $*
        do
            case $file in
                *.+(txt|rtf|rtfd|doc|docx|xml|odt|webarchive))
                    # Process each textutil supported filetype
                    /usr/bin/textutil -convert html $file
                    continue;;
                  *)
                    # dynamically add unsupported filetypes to array
                    invalid+=( "$file" )
                    continue;;
            esac
        done
        
        
        #turn off extended regular expressions
        shopt -u extglob
        # quit if no invalid files encountered
        if [[ ${#invalid[*]} -eq 0 ]]; then
            exit 0
        fi
        
        
        alertMsg="Textutil - File Conversion Unsupported: "
        # Make vertical list of unsupported files for dialog
        invalidFiles=`printf "%s\n" "${invalid[@]}"`
        
        
        #initiate AppleScript dialog for invalid files
        warn=`osascript > /dev/null 2>&1 <<-AppleScript
        
        
                tell application "SystemUIServer"
                    activate
                    display alert "$alertMsg" message "$invalidFiles" as critical
                end tell
        
        
                AppleScript`
        
        
        echo "${warn}"
        exit 0
      5. Save the Folder Action as file2html or whatever you want.
    1. It is written into /Users/login/Library/Workflows/Applications/Folder Actions/file2html (or whatever you call it)
  3. Now, back to your folder that you want to assign this action too.

    Right-button click on the folder. At the bottom of the menu is Folders Action Setup...

    1. From the drop down list of Scripts to attach, select file2html.workflow and click Attach
    2. Make sure that the current panel looks like the following:
      User uploaded file
    3. Close the Folder Actions.
    4. Test the action. I did.


I did not change any script or folder permissions, or delete any preference files to make this work. Adapt to your need.

Feb 1, 2013 2:55 AM in response to Boby51

Hi all, just ran over this post whist looking for something similar. I too have had this issue of what was a very stable in production and reliable set of apple scripts since MACOSX 10.4 that seem to somethimes stall or donot get triggered and appeared stalled (as in never started) after a folder action (delete or add) occurs. . THese are a set of FOLDER ACTION SCRIPTS on a bunch of folders.


These scripts are running on MAC OSX 10.8.2 currently on a mac mini (server).


The production scripts are mainatined locally in my home at ~/Library/scripts/Folder action scripts and are confined to a specific user that operate on a set of globally (also NFS) shared folders for others to submit and retrieve work for transcoding. THese set of applescripts controll a set number of workflows and have been working mostly flawlessly for several years.


I have posted a workaround that seems to remedy a "stuck" | untriggered folderaction script in this postin this thread at


https://discussions.apple.com/thread/4257025?answerId=21100695022#21100695022


bugaboo and myths used to attempt to kick start these scripts: I'll add that in recent times that removing fold.actions.PLISTs doesn't seem to fix any of these problems. I conceed that these .PLISTS maybe corrupted however examination under teh osx properties editor.app , they seem fine.. Also having to mess with launchctl unload and load of the two folder.action.plists, even performing a 'tick' of the folder actions deamon and even logging off and on doesnt seem to kick these scripts over. 😕


Even forcing the event (dropping or deleteing objects form the scripted folders) does seem to get these scripts going form time to time


Its a bit hit and miss when the scripts decide to take off.


However, as I posted in this thread https://discussions.apple.com/thread/4257025?answerId=21100695022#21100695022 if the script is in this state, simply..


open it up in the applescript editor.app and modify and save it. Simply adjust a comment for sample and SAVE the script again!


Then low and behold the script will trigger.


This is very consistent in the 10.8.2 that I currenly have on this server.


I'm assuming some aplescript token that is transformed after the script is compiled may be in error.


There are no /var/console messages and the event error handlers in the script NEVER get triggered so the scrips never runs. BTW, I have my own logger in these scripts to help me managae and monitor work activity...


Finally, running the script directly in a test works perfectly ofcourse..


Should someone have an exmpalanation for this I'm curious to know.


POst your results back for others to see.


Warwick

Aug 9, 2013 9:55 PM in response to Boby51

Hey everyone,

Be careful with this:


Boby51 wrote:


Was able to fix this problem without recreating user profile by deleting files below from /Users/USER NAME/Library/Preferences and letting system recreate them


User uploaded file



My computer (OSX 10.8.4) did not restore the bottom file! It only restores the top one.


Lucky, I backed it up to a zip file before deleting.


Furthermore, looking at the picture posted by Boby51, I noticed that the top file has been resently modified, but the bottom was NOT. Based on this and what happened to me, I think that whatever OSX program handles updating this plist is broken.


I'm going to attemt to change this plist file manully with xcode, perhaps it's outdated or something, but I don't know if that will help.

Aug 9, 2013 10:35 PM in response to KindnessIsNiceDuh -K.I.N.D.-

Ok, I tried to modify it with xcode, but it's no go. When I opened it, there weren't really many things to change except for some sort of last root directory thing. I tried to change that to several different folders that seemed to make sense to me. But the Folder Action did not start working.



I heard once (when I was researching something else) that change the plist files alone was not enough. Apparently, OSX does something like catching the contents of the plists for the apps that they pertain to. Who ever wrote about this gave a terminal command that forced the respective app to delete it's old catch(or whatever it's was) and load a new one from your modified plist. But I don't remember what that terminal command was any more.


I think he/she also said something about Logging Out could update the catch-like-thing, but I don't really remember too well. Either way, I tried Logging Out after modifying the plist, but this didn't appear to help.


Anyways, if anyone knows anything about how plists work and can comment on this, please help.

Thanks


And if anyone wants to try the things I was doing, I would strongly suggest backing up the files you plan to change. I do my backups simply by right clicking the files I want to save, and choosing Compress "File Name" to make zipped files.

Aug 9, 2013 11:35 PM in response to Boby51

Oh I just got it to work!

Here's what I did, if it helps anyone.


Before I start with the steps, please note that I had previously changed the permissions on my username folder (and all subfolders) to this:


Me (Read and Write)

staff (Write only)

everyone (No Access)


I believe that this may have caused some of the issues (see step 2 below).



1) After I finished trying to modify those two plist files (as I described earlier), I deleted them and restored the originals from my backups.


2) I reverted the permissions on my entire Username folder (aka. the home directory) to their default settings, such as


Me (Read and Write)

staff (Read only)

everyone (Read only)


3.a) I went to the Folder Actions Setup menu, and removed all of the actions and folders, by unticking each check mark and then pressing the minus signs.


3.b) I also unticked the Enable Folder Actions check box.


4) I think this is really important: I completely shut down my computer, (this was my attempt to allow the plist files to be recached or something, as I was describing in the above post).


5) I turned the computer on again, and from the Folder Actions Setup menu I manually assigned the desired script to my folder. BUT I did not try running the script yet.


6) I shut down my computer again, because adding the scripts meant that the plist files were updated agian, and I wanted to make sure that everything that uses those plists had the chance to see/recatch the changes.


7) When I turned my computer back on, everything worked. 🙂


Hope this helps,

🙂





Edit: Oh, if it makes a difference, I did this on OSX 10.8.4 mountain lion.

folder action not working mountain lion

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.