Run a script when folders are deleted?

I'm just playing with idea I was thinking of have a Plist in the launchd folder so that when the certain folders of the desktop are deleted it would run a script to collect information about the folders that were deleted.
Folders begining with FR and DO are moved to the trash by user, then
get number of items in each of the folder and write to a CSV file.
I just need something that will reconise the items moved to continue the rest of the script.
Any suggestions please?
Its actually to link it to this script that is a work in progress.

maybe something close to this?
tell application "Finder"
          set hotFolder to folder "Hal 9000:Users:matthew:Desktop:HotFolder"
          set keyFolder to folder "Hal 9000:Users:matthew:Desktop:Keywords"
          --The above 2 folders will always exist if there are no other folders exist on the dektop then run the rest of the script else do nothing.
          if (exists (only folder hotFolder and keyFolder)) then
                    display dialog "Only these Folders exist"
                    else
                    display dialog "Other folders exist!" 
          end if
end tell

Similar Messages

  • Launchd - can it run a script when users log in OR switch?

    I'm hoping to find someone who knows all the gory details of launchd. Here's the why and what: I'm trying to coerce Aperture into letting two users on the same computer share the same Aperture Library, both able to import photos and see and use what the other has done. Initially it is no problem, change the permissions so everyone has read/write/execute, put the Library in a common area, and point both person's Aperture at it. The problem is that Aperture changes permissions of things inside the Library as you use it, and especially when one person imports, the other person can't see that stuff.
    So I want to run a script whenever someone logs in or becomes the active user by fast user switching; the script will simply change ownership and permissions of the library and everything in it to restore full access.
    After days of research and testing, I made a test launchd plist file (this is the configuration file or agent that launchd looks at and runs your script when criteria are met). It sits in /Library/LaunchAgents/, here it is:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
    <key>Label</key>
    <string>org.jim.test</string>
    <key>LimitLoadToSessionType</key>
    <string>LoginWindow</string>
    <key>ProgramArguments</key>
    <array>
    <string>/Library/Scripts/testscript.sh</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
    <key>StandardErrorPath</key>
    <string>/Users/jim/Desktop/test.err</string>
    <key>StandardOutPath</key>
    <string>/Users/jim/Desktop/test.out</string>
    </dict>
    </plist>
    The actual test script is sitting in /Library/Scripts/:
    #!/bin/bash
    echo "org.jim.test.plist was run at `date`"
    So if the plist is loaded and the script run, the date and time are written in the test.out file on my desktop. This thing runs great when a user logs in. The problem is, it doesn't run when users switch by fast user switching. In reading the documentation, it was vague about this, whether that could be done; I thought it could.
    Can anyone help with a way to get the script to run when any user takes control by any means? As an added complication, which I'll worry about later, the script has to run as root because it's the only way to get the ownership and permissions changed.
    Thanks,
    Jim

    BobHarris is the MAN. ACLs seem to have worked. I put the Aperture Library in /Users/Shared/ApertureLibrary, restored the regular permissions as best I could (me as owner, staff as group, 755), pointed each person's Aperture to the library, then proceeded with the ACL magic. First I created a group for my wife and I, called 'aperture', in the Accounts preference pane. That was to simplify the ACLs (one entry instead of 2) and so that other users (son) aren't able to muck it up.
    It took one stinking Terminal command (note that 'aperture' at the beginning of the quote is the group, not the program, folder or library):
    chmod -R +a "aperture allow list,addfile,search,delete,add_subdirectory,delete_child,file_inherit,directoryinherit" ApertureLibrary.aplibrary
    I was unsure whether this list of permissions was necessary or sufficient, but it seems to have worked so far. Both users can access the library. I imported a different picture by each user, and the other user could then see and delete the picture imported by the other. This was not possible before.
    Bob, thanks for the great idea. After a little more testing I'll post a complete how-to in the latest "how do we share Aperture" thread, and give you due credit. The bad news is all the launchd fun is over
    Jim

  • How to use java script when popups are blocked in browser

    How to use java script when popups are blocked in browser

    Not. When people install a popup blocker they don't WANT popups, so stop trying to force them down their throats.

  • Why is it on the photo app is that when you add your photos to new albums and when you are deleting from camera roll it will delete photos from everywhere so therefore once your photos are in the albums you have chosen you cannot delete f

    Why is it on the photo app is that when you add your photos to new albums and when you are deleting from camera roll it will delete photos from everywhere so therefore once your photos are in the albums you have chosen you cannot delete from camera roll

    Your photos are actually all in the Camera Roll.  The album you create only contain pointers to these pictures.  Albums are like music playlists; when you delete a song from the playlist it doesn't delete the song from your music library.  But when you delete a song from your music library it will also be deleted from any playlists that it may have been in as well.

  • Camera SD card folders are deleted

    Yesterday, some of my camera memory card folders were deleted mistakenly when editing some stored photos on my computer. All of them were gone and could not be found in Recycle Bin. Do you know where these folders are? They all had not been backed up yet. Is it possible for me to rescue them all back? Thank you for any suggestion! 

    If you haven't reformatted or saved any new photos to the card you may be able to recover them. Try this:
    http://www.cardrecoverypro.com/?cate=error&model=sandisk-Card&item=photos&action=rescue&situation=nu...
    John Hoffman
    Conway, NH
    1D Mark IV, Rebel T5i, Pixma PRO-100, MX472

  • Have terminal NOT run a script when it loads

    I recently wrote a basic shell script and saved it as a .command file to run from the desktop. Since then, whenever I open the terminal it automatically runs the script then exits the terminal. If I hide the file (mv pt-noplugs.command .ptnoplugs.command) it simply opens the terminal and closes it immediately. I have tried changing the default shell from bash to something else but this doesn't seem to make a difference. I also don't seem to have a .bashrc file when it normally is /home/user/.bashrc (I'm used to linux). Any help would be appreciated. Below is the script:
    # Shell Script to start Pro Tools HD with no waveshell Plug-In
    echo "*"
    echo "* Script: pt-noplugs.command"
    echo "* Please Leave This Window Open Until ProTools Has Exited"
    echo "*"
    # Move waveshell Plug-In Files to Plug-Ins (Unused)
    cd "/Library/Application Support/Digidesign/Plug-Ins/"
    mv -v Waveshell-DAE_5.9.1.dpm "../Plug-Ins (Unused)"
    # Start Pro-Tools
    /Applications/Digidesign/Pro\ Tools/Pro\ Tools\ HD.app/Contents/MacOS/Pro\ Tools\ HD
    # Restore Plug-Ins directory
    cd "../Plug-Ins (Unused)"
    mv Waveshell-DAE_5.9.1.dpm ../Plug-Ins
    echo "*"
    echo "* Thank You. This Window May Now Be Closed"
    echo "*"
    exit

    I forgot to add: when I login as a different user and load terminal is does NOT run the script mentioned before.

  • Are previews deleted when photos are deleted?

    After being confused for a while (as I'm sure many are) about not being able to delete photos from my memory card from Lightroom, I am trying to get into a "correct" workflow which I believe involves formatting the card when I have saved and backed up the images on it. So far I've come to this:
    0) Start with an empty memory card and take photos with my camera
    1) Import all photos, selecting to create 1:1 previews
    2) Look through the imported photos, marking the ones I never want to look at again as Rejected
    3) Delete Rejected photos
    4) Backup everything that is left
    5) Format memory card
    This seems to work, but I just want to make sure that the 1:1 previews created during the import of the photos that I Reject are deleted at the same time as the Rejected photos are deleted, so that they are not part of the backup step. Is this the case?
    Also, are there any other problems with this workflow?
    Thanks,
    David

    Previews should not be in the same folder hierarchy as the actual images.
    With regards to rejecting photos, there are pros and cons to each approach. I just import everything.
    I don't know if previews are deleted immediately when the image is deleted, I don't worry about it, I have never had a need to see whether a particular preview exists in the preview cache, so actually I don't know the answer. Why does it matter? Is your disk so close to being full that you are worried about it? that's the only possible reason I can think of to worry about what exists and doesn't exist in the previews cache, and since Lightroom does a very good job of managing these preview files so the human user doesn't have to, I would recommend you not worry about it. There's enough to do managing your actual images so my advice is to not worry about what is and is not in the preview cache.

  • Is it possible to run a script when changing Yoga modes?

    I'm currently working with a vendor of Restaurant reservation software and they have a customer that would like to implement the Yoga 13 for a chain of hotels. However, due to the fact that the software requires Silverlight, it's necessary to run a script so that they can use Google Chrome and have the software keyboard pop up automatically when a text field is entered or touched. 
    I can easily run the script at login and manually unload it when done, but since Lenovo already has software (Lenovo Transition) that can trigger things when the Yoga changes modes, is there some sort of developer tool or a system-wide event that can be used to automatically load and unload the script on mode change?
    Please let me know, some Yoga sales could depend on this....and I love the Yoga.

    Well, I'm looking for a means to activate a script through the active corners, I'm not asking any questions about the script itself, so I did not think it should be posted in the AppleScript categoriy, but sure, I'll give it a go.
    (New thread in AppleScript: http://discussions.apple.com/thread.jspa?threadID=2534773&tstart=0)
    Message was edited by: Max Ocklind

  • Time Machine - how does it handle a full disc when increments are deleted?

    I have a 500G.
    I could not find any info on the following, so would greatly appreciate help.
    My understanding of how it works is
    - there is an initial backup - FULL (step0)
    - the next steps are incremental i.e.
    - step 1 is a delta between the state at the time and step0
    - step 2 is the difference between the state at the time and step1
    - etc
    The questions are the following
    1) will there ever be another FULL backup? or all are from step0 on incremental?
    2) if the disk is full, what will be deleted?
    2a) if an intermediate step is deleted how will the TIme Machine build the next step??
    3) if I need to recover/restore, will it start from step0 and then apply step1, step2, step3, etc till it is complete?
    3a) if this is the case, how are "deletions" handled, in case there is no more disc space (previous question)
    many TIA!
    luis

    luissimoes, Welcome to the discussion area!
    These are really Time Machine questions not Time Capsule questions.
    1) will there ever be another FULL backup? or all are from step0 on incremental?
    No and yes.
    2) if the disk is full, what will be deleted?
    From what I understand (and I could be wrong)...
    The files deleted from the source drive starting with the earliest ones deleted. i.e. files deleted on Jan 1 will be removed from the backup before those deleted on Jan 2.
    After the deleted files have been removed. The oldest versions of files with multiple versions will be deleted.
    2a) if an intermediate step is deleted how will the TIme Machine build the next step??
    A complete intermediate step would only be deleted if all the files involved had been deleted from the source drive or newer versions of those files were already backed up.
    3) if I need to recover/restore, will it start from step0 and then apply step1, step2, step3, etc till it is complete?
    Doubtful. That would be horribly inefficient even if nothing was ever removed from the Time Machine backup.

  • Run a script when DND is on

    I saw that Messages.app has an AppleScript handler and I thought about making a script to change my status to "Away" or "DND" when Do Not Disturb feature of Notification Center is on. But I don't know how to "talk" to AppleScript regarding the DND feature of NC. I used AppleScript once or twice for simple tasks when I told Finder or Mail to do something simple, but now I don't know how to do this.
    I think that the "pseudocode" should be something like
    tell application "Messages" to (if DoNotDisturb is ON set status to "Away")
    but I don't know how to make it understandable by AppleScript. More precisely, I don't know how to refer to the DND state of Notification Center.
    Any help well appreciated. Thanks.

    Hi,
    If you Open AppleScript Editor you can use the File Menu to Open Dictionary.
    You will get a window full of the apps and items that have AppleScript Dictionaries.
    From here I opened the System Preferences one (There seemed to be no Notifications one)
    I looked at the two sets of items (Standard Suite and System Preferences).
    The second seems to be the one to use.
    It seems you could get AppleScript  to reveal the Panes and the Anchors as they are called within the pane.
    However when I try:-
    using terms from application "System Preferences"
        reveal pane
    end using terms from
    I get an error message.
    At this point my skills at AppleScript are exceeded to know what to do next.
    Aside from that Messages 7 (Mountain Lion) and earlier iChat version had an Alert section to the Preferences.
    These had seventeen different actions of things that could be set such as Buddy Coming On-line (Available), Messages Sent and well as th Message Received that is now in the General Section.
    You could set Sound, Dock icon bounces and Applescripts to each of these.
    I had two;  the first was set for AV Chat Started which changed the Status Message and the Input and Output volumes and the second for AV Chat Ended which said I had been busy but was no longer and changed the volume back.
    I would have to run these as External Scripts (not set in the option you describe) but I have not down this yet.
    I don't think the current option can be set to anything other than Message Received and you want to do things to the Status Message before then, control be an event in another app.
    10:14 pm      Saturday; January 25, 2014
      iMac 2.5Ghz 5i 2011 (Mavericks 10.9)
     G4/1GhzDual MDD (Leopard 10.5.8)
     MacBookPro 2Gb (Snow Leopard 10.6.8)
     Mac OS X (10.6.8),
     Couple of iPhones and an iPad

  • How can I run a script when an application quit??

    Greetings all,
    I'm trying to write a script, which can be triggered automatically (to do some stuff) at the time when a given application quit. I was playing around with this test script, taking "TextEdit" as an example - it just prints a message when TextEdit exits.
    ==========================================
    +*set targetapp to "TextEdit"*+
    +*tell application "System Events" to set rr to name of the processes*+
    +*--if targetapp is not in rr then*+
    +*-- tell application targetapp to activate*+
    +*-- tell application "System Events" to set rr to name of the processes*+
    +*--end if*+
    +*set rr1 to rr*+
    +*repeat until rr1 ≠ rr and targetapp is not in rr1*+
    +*tell application "System Events" to set rr1 to name of the processes*+
    +*do shell script "sleep 1"*+
    +*end repeat*+
    beep
    +*display dialog (targetapp & " is not active anymore !") as string buttons {"OK"} default button 1 with icon 0*+
    ============================================
    Unfortunately, it seems to work if I launch TextEdit using the script itself; it doesn't work with first +*"if - end if"*+ block commented out. Does anyone know how can I achieve this? Any help or suggestion greatly appreciated. Cheers!!

    Hi santanu,
    I'm sure you can use a variation of this application of mine to do what you want. It monitors all running processes and then reports when one closes.
    --initialize previous_processes
    global previous_processes
    tell application "Finder"
    set previous_processes to get the name of every process --use "whose visible is true" to remove the background ones
    end tell
    --monitoring script
    on idle
    tell application "Finder"
    set current_processes to get the name of every process
    end tell
    set numberofprocesses to count of items in previous_processes
    set counter to 1
    repeat while counter is less than (numberofprocesses + 1)
    if current_processes does not contain item counter of previous_processes then
    display alert item counter of previous_processes & " quit!"
    end if
    set counter to counter + 1
    end repeat
    set previous_processes to current_processes
    return 1 --runs every second...can be changed
    end idle

  • What happens to versions data when files are deleted ?

    When working on a document with an application using autosave, I understand modifications are regularly saved together with the actual state of the file. When such file is dulicated, history and the different versions are not duplicated.
    My question is, what happens to the versions data if the original file is deleted and is the space used for all versions reclaimed ?
    Working with big documents on SSD disk could be a problem seems to me.
    Thanks for your comments.

    Hi Tony,
    As soon as data is deleted from the cube, Data will not be available for reporting. because for any reports data is fetched from Tables, for DSO they will fetch from Active table.
    So you will receive a message Data not found, if the data is deleted from Cube's table.
    Assign some points, if this is helpful.
    Rgs,
    I.R.K

  • "Fatal error, run database recovery " when there are no txns to recover.

    Hi, all.
    I have a DB file containing multiple databases. Without using DBEnvironments, I can open it to get the dbnames. I can open the databases RDONLY,
    and see that their contents are correct. I can open them RW, and everything works.
    But when I try to create a new one, I get this:
    D = bsddb3.db.DB()
    D.open('test.db',dbname='test',dbtype=B.DB_BTREE,flags=B.DB_CREATE)Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    bsddb3.db.DBRunRecoveryError: (-30974, 'DB_RUNRECOVERY: Fatal error, run database recovery -- PANIC: fatal region error detected; run recovery')
    Note that this is in the non-transactional case. There is no Env, and there are no logfiles or __db files. So the error code mystifies me.
    Strace shows that the file is opened RW, and read through.
    B.DB_VERSION_STRING'Berkeley DB 4.8.24: (August 14, 2009)'
    >>>
    So, where to proceed? Many thanks for any and all help.

    Hmm. Other thing to note:
    [tradedesk@vader 2010-05-06.test]$ /usr/local/BerkeleyDB.4.8/bin/db_verify foo.db
    db_verify: Subdatabase entry references page 266 of invalid type 13
    db_verify: Page 0: non-invalid page 40 on free list
    db_verify: trading.db: DB_VERIFY_BAD: Database verification failed
    Not sure how that came about or how to prevent it, but it might have to do wit this issue.

  • HT201304 Is there a way to check my childs messages when they are deleted and by not searching my childs iPod?

    Can I check my childs deleted messages without searching my childs iPod?

    To add a bit, the suggestion by IIIaass will work if you already have done this. It will not work if you are not already sharing the same Apple ID and you are looking for specific messages they have already deleted.
    Also if you are going to share the Apple ID you need to turn on Restrictions and lock down their device so they cannot go into the Touch and change to a different Apple ID when they leave the house.

  • Error Script when try to delete records under condition

    Dear Members
    I have a problem when i try to delete a record at MDX script into BOC
    I have the follow problem
    TIME FLOW C_DATASRC ENTITY INTCO CONSGROUP RPTCURRENCY C_CATEGORY C_ACCT DIVISION SEGMENT SIGNDATA
    2011.FEB VALID INPUT CIA12 I_CCO11 NON_GROUP GC C_110 2204002 1014 S999 17.272.941,9500000
    2011.FEB CCO11 INPUT CIA12 I_NONE NON_GROUP GC C_110 1205002 1014 S999 1,4870000-
    2011.FEB VALID INPUT CIA12 I_CCO11 NON_GROUP GC C_110 1205002 1014 S999 17.272.941,9500000-
    2011.FEB CCO11 INPUT CIA12 I_NONE NON_GROUP GC C_110 2204002 1014 S999 34.545.885,3870000
    Condition
    2011.FEB NA INPUT CIA12 I_CCO11 NON_GROUP GC C_110 NA 1014 S999 31.405.349,0000000-
    IF C_ACCT.NA = -31.405.349,00 is LESS than 0 delete value of C_ACCT2204002  (17.272.941,95 and 34.545.885,387)
    IF C_ACCT.NA = -31.405.349,00 is Greater than 0 delete value of C_ACCT1205002 (-1,487 and -17.272.941,95)
    I get the record 31.405.349,0000000- from de account NA, with this record i try to determine if i delete the valoe of account 1205002 or 2204002, but my script delete the 4 values.
    I replaced the 0 for 5 and work, but i what to delete the records
    2011.FEB VALID INPUT CIA12 I_CCO11 NON_GROUP GC C_110 2204002 1014 S999 17.272.941,9500000
    2011.FEB CCO11 INPUT CIA12 I_NONE NON_GROUP GC C_110 2204002 1014 S999 34.545.885,3870000
    And leave
    2011.FEB CCO11 INPUT CIA12 I_NONE NON_GROUP GC C_110 1205002 1014 S999 1,4870000-
    2011.FEB VALID INPUT CIA12 I_CCO11 NON_GROUP GC C_110 1205002 1014 S999 17.272.941,9500000-
    // VPP
    // BORRA REGISTRO DUPLICADO
    *XDIM_MEMBERSET CONSGROUP = NON_GROUP
    *XDIM_MEMBERSET C_ACCT = NA, 1205002, 2204002
    *XDIM_MEMBERSET C_CATEGORY = C_110
    *XDIM_MEMBERSET C_DATASRC = INPUT
    *XDIM_MEMBERSET DIVISION = 1014
    *XDIM_MEMBERSET ENTITY = CIA12
    *XDIM_MEMBERSET INTCO = I_NONE,I_CCO11
    *XDIM_MEMBERSET FLOW = NA,VALID,CCO11
    *XDIM_MEMBERSET RPTCURRENCY = GC
    *XDIM_MEMBERSET SEGMENT = S999
    *XDIM_MEMBERSET TIME = %TIME_SET%
    *WHEN FLOW
    *IS "NA"
    *WHEN C_ACCT
    *IS "NA"
    *WHEN INTCO
    *IS "I_CCO11"
    //Elimina Diferencia
    *REC(EXPRESSION=((%VALUE% > 0) * 0), C_ACCT = "1205002", FLOW = "CCO11", INTCO = "I_NONE")
    *REC(EXPRESSION=((%VALUE% < 0) * 0), C_ACCT = "2204002", FLOW = "CCO11", INTCO = "I_NONE")
    //Elimina Validador
    *REC(EXPRESSION=((%VALUE% > 0) * 0), C_ACCT = "1205002", FLOW = "VALID", INTCO = "I_CCO11")
    *REC(EXPRESSION=((%VALUE% < 0) * 0), C_ACCT = "2204002", FLOW = "VALID", INTCO = "I_CCO11")
      *ENDWHEN
    *ENDWHEN
    *ENDWHEN
    *COMMIT

    instead of %VALUE % use MDX  ie
    *WHEN FLOW
    *IS "NA"
    *WHEN C_ACCT
    *IS "NA"
    *WHEN INTCO
    *IS "I_CCO11"
    //Elimina Diferencia
    *REC(EXPRESSION=(([INTCO].[I_CCO11] > 0) * 0), C_ACCT = "1205002", FLOW = "CCO11", INTCO = "I_NONE")
    *REC(EXPRESSION=(([INTCO].[I_CCO11]  < 0) * 0), C_ACCT = "2204002", FLOW = "CCO11", INTCO = "I_NONE")
    //Elimina Validador
    *REC(EXPRESSION=(([INTCO].[I_CCO11]  > 0) * 0), C_ACCT = "1205002", FLOW = "VALID", INTCO = "I_CCO11")
    *REC(EXPRESSION=(([INTCO].[I_CCO11]  < 0) * 0), C_ACCT = "2204002", FLOW = "VALID", INTCO = "I_CCO11")
    u3000u3000*ENDWHEN
    *ENDWHEN
    *ENDWHEN
    hope this helps

Maybe you are looking for